[antlr-interest] How to fix reference counting circular problem(C++)?

Ric Klaren ric.klaren at gmail.com
Mon Jan 17 06:52:32 PST 2005

On Mon, 17 Jan 2005 09:22:41 -0500 (EST), Fan Yang <fanyang_32 at yahoo.ca> wrote:
> I have memory leaks on deleting CommonHiddenTokens(double link list) which
> there exist reference counting circular problem. 
> I have searched on antlr archives, and  found that same problem was
> discussed in "nodes, hidden tokens, garbage collection" topic in 2002
> archive, but it didn't give me the solution. 

Can't add anything other than the reply I gave then. You could prior
to deleting the AST destroy the double links by setting them to

> Now almost 3 years passed, is there a mature and practical solution on this
> problem? Has the new antlr release fixed this problem?
> any suggestion will be appreciated. 

The 2.7.5 release does not change the reference counter. It was
planned to switch to another but it ran into some trouble I could not
solve quickly in the prerelease track. The new one would not have
solved this problem either.

At some point I intend to get rid of the reference counters and move
to custom allocators with optional garbage collection or manual memory
management. ANTLR3 will probably see that. Don't know if I'll have
time to do it for ANTLR2.



More information about the antlr-interest mailing list