Menu

#4 Memory leak in generated parsers

open
nobody
None
5
2009-06-28
2009-06-28
No

Reusing a parser instance (DeterministicParser or BacktrackingParser) results in a memory leak caused by the method lpg.runtime.Stacks.reallocateStacks(). This method is called before parsing a new file and it will copy the current stacks into new arrays of length "stack_length = old_stack_length + STACK_INCREMENT;". Because of this the stacks will continue to grow when reusing a parser.

A potential fix for this bug is adding the following lines to the reset method in the DeterministicParser/BacktrackingParser:
locationStack = null;
parseStack= null;
stateStack= null;

Discussion


Log in to post a comment.