[antlr-interest] Re: Memory Leak?

Ric Klaren klaren at cs.utwente.nl
Sun Jun 6 04:53:22 PDT 2004


On Sun, Jun 06, 2004 at 12:16:47AM -0000, lgcraymer wrote:
> That is probably right-- CommonAST::~CommonAST() does not delete its
> "text" field; CommonToken has a similar "feature" since it inherits
> its destructor from Token.  That may not be easy to fix, short of
> adding ref-counted strings.  Ric may have a suggestion.

It's a normal attribute so it does not need an explicit delete. If it had
been a pointer to a string then it would be missing a delete. AFAIK the
base library has no or neglectible memory leaks (last time I checked). In
the case the text strings don't get deleted then you got a buggy
compiler/standard library.

It would be helpfull to know antlr version, compiler version. Also details
like using a custom ast and such.

With the refcounted ast's it's pretty easy to do something that leaves a
reference to a complete ast floating about which results in the whole thing
not getting deleted. (or if you made a circular reference with a custom ast)

One could add a static counter to the constructor/destructors of the ast
classes and see if the complete ast gets deleted. Or compile with a memory
tracker that gives more precise information.

> > From what I can tell from my investigations, it's
> > storage for strings allocated by ANTLR when building
> > the trees that isn't getting freed.

It can also be that this is part of your standard libraries
implementation.... It is common to have a few chunks of memory floating
around after program exit, due to internal buffers storage of the support
libraries of a compiler.

Cheers,

Ric
-- 
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755  ----
-----+++++*****************************************************+++++++++-------
 'And this 'rebooting' business? Give it a good kicking, do you?' 'Oh, no,
  of course, we ... that is ... well, yes, in fact,' said Ponder. 'Adrian
    goes round the back and ... er ... prods it with his foot. But in a
     technical way,' he added. --- From: Hogfather by Terry Pratchett.



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list