Debugging memory leak.

Brad Roberts braddr at puremagic.com
Mon Oct 8 12:28:08 PDT 2007


On Mon, 8 Oct 2007, Frits van Bommel wrote:

> Sean Kelly wrote:
> > David Brown wrote:
> > > 
> > > Ideas for possibly fixing this:
> > > 
> > >   - Manually 'delete' these buffers.  In my instance, this wouldn't really
> > >     be all that difficult since I know when they go out of use.
> > > 
> > >   - Call std.gc.hasNoPointers(void*) on the block.  I would think this is
> > >     the case for a char[], but std.zlib.compress uses a void[], which the
> > >     compiler can't make this assumption about.
> > 
> > std.zlib should likely be changed to use a byte[] array instead.
> 
> Yes it should. I created a quick patch for the gphobos version of std.zlib
> (since the OP was using GDC). I attached it to this post (not pasted inline
> due to line wrapping issues).
> I haven't tested it other than running it through 'gdc -c', but it's such a
> trivial patch that the fact it compiles should mean it should function
> identically (except for not allocating void[]s, and thus hopefully prevent
> some memory leakage).
> 
> > >   - Try Tango?  Is the GC different there?
> > 
> > Somewhat, but void[] arrays are still treated as if they have pointers.
> 
> But AFAICT tango.io.compress.Zlib doesn't allocate any of those, just ubyte[]
> arrays, and exception classes. (The unittest does use a MemoryConduit, which
> internally uses a void[], but nothing else should allocate void[]s for that
> module)

Please attach that diff to a bug report so that it doesn't get lost.  I'll 
look at it getting it into the next release.

Thanks,
Brad



More information about the Digitalmars-d mailing list