Re: OutOfMemoryError on big text chunk
"Mirko Nasato" <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Thanks Attila. I had a quick look at the code and class FMParser is generated by JavaCC so I'm not sure how easy it would be to change it, but my guess is that if you could split a big block of text into smaller pieces when parsing that would avoid memory usage from growing exponentially. E.g. instead of buffering the entire 5.7M string and creating a single TextBlock, limit the buffer to say 512k and create a new TextBlock whenever you reach that limit. Or something like that. BTW when I opened the same file in Eclipse it caused an OutOfMemoryError in Eclipse as well! I had to revert to the good old VIM to edit it. ;-) Cheers Mirko On 16/12/2007, Attila Szegedi < [email protected]> wrote: > > I've entered this into our bug tracker: > > > http://sourceforge.net/tracker/index.php?func=detail&aid=1851842&group_id=794&atid=100794 > > I'll try to reproduce and inspect it as I can. > > Attila. > > On 2007.12.14., at 19:00, Mirko Nasato wrote: > > > Hi all, > > > > I'm processing a 5.7M XML template through FreeMarker (version > > 2.3.11). With -Xmx128m I get an OutOfMemoryError > > > > Exception in thread "main" java.lang.OutOfMemoryError : Java heap space > > at java.util.Arrays.copyOf(Arrays.java:2882) > > at > > java > > .lang > > .AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100) > > at > > java.lang.AbstractStringBuilder.append (AbstractStringBuilder.java:390) > > at java.lang.StringBuffer.append(StringBuffer.java:224) > > at freemarker.core.FMParser.PCData(FMParser.java:2497) > > at freemarker.core.FMParser.Content(FMParser.java :2570) > > at freemarker.core.FMParser.OptionalBlock (FMParser.java:2784) > > at freemarker.core.FMParser.Root(FMParser.java:2956) > > > > with -Xmx192m it works. > > > > The template does not actually contain any FreeMarker instructions > > (it's an ad hoc test to reproduce the problem). If I put a random > > expression like ${foo!} in the middle of the document then it works > > with less memory, -Xmx96m is enough. > > > > So I guess the problem may be with big chunks of text without any > > expressions (TextBlock?). But the whole file being 5.7M, why does it > > need more than 128M to do the parsing? > > > > Thanks > > > > Mirko > > > > > > > ------------------------------------------------------------------------- > SF.Net email is sponsored by: > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services > for just about anything Open Source. > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > _______________________________________________ > FreeMarker-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/freemarker-user > ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ FreeMarker-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freemarker-user