[antlr-interest] Freeing memory as you go using C target

Peterson, Joe joe.peterson at intel.com
Thu Jun 4 13:27:23 PDT 2009


Hello all,

We're using the C target to generate a parser for a very large file with very large independent sections.  Unfortunately, it's consuming 1GB+ of memory when parsing the file.  Is there any way to free up the memory consumed as we go without pre-parsing the file to chunk it up?  Everything I've found in my searches seem to point to splitting up the file before processing it. After a particular token, can we free the memory used by that token?  For example if we had:

contents : header body footer;
header : BLAH BLAH BLAH;
footer : BLA BLA BLA;
body : section+;

section 
@after {
	// can we free everything here even though we're still in body?
}
    : LBRACE morestuff RBRACE;


Thanks,
-JEEP


More information about the antlr-interest mailing list