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

Terence Parr parrt at cs.usfca.edu
Tue Jun 5 11:51:22 PDT 2007


On Jun 5, 2007, at 11:18 AM, Wincent Colaiuta wrote:

> 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.

That is really really strange. Are you sure that the commandline  
version is v3.0?

Ter



More information about the antlr-interest mailing list