Garbage collector memory leak "feature"?

0ffh spam at frankhirsch.net
Wed Oct 10 08:14:34 PDT 2007


Steven Schveighoffer wrote:
> Yeah, I'd say if you are relying on void arrays to store your pointers,
> you should be SOL.  If you want to use void[] to contain pointers, you
> should also have to maintain the pointer somewhere else as well to
> prevent the memory from being collected.  Can anyone give an example of
> where this is *necessary* and not just convenient?

If you want to keep extra copies of your pointers, then just do it for
glod's sake, and use ubyte[] for memory allocation!
There is no need at all  to change the behaviour of the gc WRT void[].

> Would it be possible to allow for optimizations for people who are not 
> interested in garbage collection, but are interested in speed/mem usage,
> to use some other memory allocation scheme that does not use the garbage
>  collector?  Then throw away the assumptions that have caused these
> leaks to occur (e.g. void[] can contain pointers)?

IIRC just use std.c.malloc to get unmanaged memory blocks.

> to me, gc-that-leaks-memory-by-assuming-random-data-is-a-pointer ==
> broken gc.  Speed/mem usage is secondary.

Well, the rest of us calls it "conservative garbage collector"... =)

Regards, Frank



More information about the Digitalmars-d mailing list