[antlr-interest] java.lang.OutOfMemoryError: Java heap space

Wincent Colaiuta win at wincent.com
Tue Jun 5 11:18:39 PDT 2007


I'm trying to develop a parser for wiki markup and part of that  
requires the recognition of URI tokens according to RFC 3986 (<http:// 
www.ietf.org/rfc/rfc3986.txt>). The internal structure of the URI  
isn't of any interest to me, I just want to get a token for each URI,  
so I'm doing all this in the lexer.

For testing purposes, I'm doing this first in a separate grammar,  
which you can see here:

   <http://pastie.textmate.org/68006>

Basically this is the grammar from the RFC, but converted from the  
ABNF used in that document (the ABNF is itself described in <http:// 
www.ietf.org/rfc/rfc2234.txt>) to use ANTLR's EBNF notation, and then  
with some minor tweaks to eliminate ANTLRWorks warnings about  
ambiguity or analysis problems. As far as I can tell, however, the  
grammar matches the description in the RFC.

When I try to pipe this through ANTLR (v3 final) I get this:

   Exception in thread "main" java.lang.OutOfMemoryError: Java heap  
space

I tried cranking up the heap size, 256 MB, 512 MB, 768 MB and so on...

   java -Xms32m -Xmx2048m org.antlr.Tool RFC3986.g

But to no avail... I got up to almost a gig and a half before swap  
start thrashing itself to death and I had to kill the ANTLR process.  
The funny thing is the grammar check works fine in ANTLRWorks (no  
warnings printed to the console), it has no problems showing me  
syntax diagrams, producing rule dependency graphs, or handling input  
that I pass in via the interpreter.

I tried this with both C and Java as the target language, so the  
problem seems to be language independent. From what I've read on this  
list I guess the cause is something nasty in my grammar that I'll  
need to work around. The trouble is, I don't even know where to begin  
to look. Can anybody provide some pointers?

Cheers,
Wincent



More information about the antlr-interest mailing list