Re: Memory Managment issues
Stefan Seefeld <[email protected]> Thu, 25 Jan 2007 15:25:58 -0500
| Newsgroups | gmane.comp.documentation.synopsis |
|---|---|
| Message-ID | <[email protected]> |
Luke Petre wrote:
> Howdy all. I'm unfortunately unable to use the latest Synopsis release,
> but a quick browse of the head revision in SVN makes it seem like the
> problems I'm having are still around.
>
> There appears to be at least two memory management schemes used by
> Synopsis.
>
> Synopsis::SymbolTable::Scope uses a reference counting scheme. It
> severely leaks memory, as the SymbolFactory does not properly release
> references, nor does the walker, and every nested Scope creates a
> circular reference. This was a pretty straight forward fix, changing
> the code to have the outer scopes hold a reference to the inner scopes,
> and adding the proper refs and unrefs in the factory and walker. I hope
> I can make this change into a .patch file to submit back to the main
> branch.
You are (unfortunately) quite correct. I have been meaning to fix this
for quite a while, but never got around to it. The SymbolTable isn't
even used yet, in the release branch. (It just consumes memory. :-( )
In the development branch, it is used, and there I'd definitely like
to fix the way memory is managed. In fact, I have been pondering
using boost code heavily (for smart pointers, the filesystem access,
as well as to replace my own poor-man's implementation of a 'python C++ API'
by boost.python). Needless to say, I'd welome any help I could get.
> Secondly there are the objects in the Synopsis::PTree namespace which
> use the Boehm GC library. This appears to be based on the OpenC++
> parser, so I believe it generally works w/ respect to memory
> management. The one place I do notice a difference is in the Encoding
> class. In the OpenC++ parser, that class has a character buffer with a
> fixed size. In the Synopsis implementation it uses a std::string. This
> causes problems because the std::string is ultimately owned by a garbage
> collected object, but is allocating memory from a non-garbage collected
> heap.
Why is this a problem ? You are right in that the PTree classes are descendants
from OpenC++, but, in contrast to OpenC++, I now use the Boehm GC only and
exclusively for PTree nodes. But, as these are ordinary C++ classes, their
destruction will release (i.e. destruct) all member variables, no matter
what that means. Right ?
Thanks,
Stefan
--
...ich hab' noch einen Koffer in Berlin...