0

I have written a parser in ANTLR3. Targets are both Java and CSharp3. Both are using a lot of memory at parse time. The files I am parsing have a size between 5 and 40 MB. Memory Usage is far beyond that, iirc correctly a .NET Memory profiler showed a peak of over 600MB. The grammar file has about 500 lines. I just need the output generated by my injected Code in the grammar. I do not need all lexer tokens in memory or the AST.

Is there anything I can do? Does ANTLR4 address memory usage issues?

metacircle
  • 2,438
  • 4
  • 25
  • 39
  • This is application specific. What else did you get from the profiler report? You should carefully analyze the memory usage and track down suspicious spots before blaming ANTLR. – Lex Li Jun 03 '13 at 06:56
  • It is/was ANTLR3s fault. I was only profiling the naked ANTLR parser. I have moved on to ANTLR4, Memory Usage now is only 1/3rd of ANTLR3 equivalent. – metacircle Jun 03 '13 at 12:29
  • ANTLR4 uses a modified algorithm, and its design goals have changed from v3. Though low memory usage is not obviously a goal, v4 might have a different pattern. Unless you use the parser in a web application, I don't think 600-MB is too much. – Lex Li Jun 03 '13 at 21:58

0 Answers0