dcsimg
How to get rid of CommonHiddenStreamToken memory leak in C++?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Gabor_Drasny
Posted On:   Monday, April 18, 2005 12:09 PM

I am using CommonHiddenStreamTokens in combination with TokenStreamHiddenTokenFilter to preserve comments while building the AST. I noticed that if there were two or more consecutive hidden tokens (comments in my case) then these tokens would never be deleted. Let's say the unfiltered token stream starts with two hidden tokens ( H1 , H2 ) followed by a non-hidden one ( T1 ). Then the linked list of tokens will look like (the links being hiddenBefore and hiddenAfter): H1 <-> H2 <- T1 When T1 is being destroyed eventually it will decrease the reference count for H2 , but will not delete it, since H1 is still referencing it. At the    More>>

I am using CommonHiddenStreamTokens in combination with TokenStreamHiddenTokenFilter to preserve comments while building the AST. I noticed that if there were two or more consecutive hidden tokens (comments in my case) then these tokens would never be deleted.


Let's say the unfiltered token stream starts with two hidden tokens ( H1 , H2 ) followed by a non-hidden one ( T1 ). Then the linked list of tokens will look like
(the links being hiddenBefore and hiddenAfter):


H1 <-> H2 <- T1


When T1 is being destroyed eventually it will decrease the reference count for H2 , but will not delete it, since H1 is still referencing it.
At the end of the program the memory will look like:


H1 <-> H2


Is there an easy way to get rid of these hidden tokens?

   <<Less
About | Sitemap | Contact