So, in this case, the problem is because PEG is backtracking because of bad markup where {{foo|.. escapes a nowiki because of a markup error. This causes the rest of the page to be processed as a potential template argument, and then on hitting EOF and not seeing a closing }}, PEG backtracks all the way to that line and retries a different tokenization. The backtracking cache ensures that retry can now benefit from previous parses of a number of substrings. *But*, the backtracking cache swells with cached info for the rest of the page.
The backtracking issue can be reproduced with this sample snippet:
* a {{bar|1
* b
== h ==
cTo fix OOM fails on markup errors like this, we need to fix handling of these kinds of broken markup. One crude fix is to limit cache memory available to PEG. This will require fixes to the wikipeg library.