[antlr-interest] Java code generator memory optimization
Akhilesh Mritunjai
virtualaspirin at yahoo.com
Sat Sep 24 07:02:29 PDT 2005
Hi everybody
Sorry have been totally out of touch lately. (Deepest
apologies to you, Terence).
I have been able to reduce memory requirement for my
AST tree generated by parser by upto 25% by using
intern() function of String class to get reference of
an string object from internal JVM string pool.
Changes required are:
Function CommonAST.setText(String text_)
- text = text_
+ text = text_.intern()
Obviously it was a hack. Proper way to do it is to
modify lexer code and use "new
String(char[]).intern()" where we do just "new
String(...)".
String.intern() has been present since JDK1.2 so it
shouldn't pose compatibility problems.
Secondly, I still push forward inclusion of an option
"useDupTree" in tree parser. This will call dupTree()
rather than dup() on current node when option
"buildAST" is true. This allows me to make stages that
do pure tree-to-tree transformations with no
side-effects, with just wring grammar for nodes of
interest rather than entire tree.
Thanks
- Akhilesh
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
More information about the antlr-interest
mailing list