OSNews article about C++09 degenerates into C++ vs. D discussion
Sean Kelly
sean at f4.ca
Sun Nov 19 20:34:01 PST 2006
Kyle Furlong wrote:
> Bill Baxter wrote:
>> Julio César Carrascal Urquijo wrote:
>>> Mars wrote:
>>>> http://www.osnews.com/comment.php?news_id=16526
>>>
>>> This is one thing that bothers me with the current GC. If you store
>>> data with a lot of entropy in an array (Sound, encrypted data, sensor
>>> data, etc...) you start to experience memory leaks because the GC
>>> starts to see the data as references to other objects.
>>
>> This is the kind of comment that scares me.
>> How does one reconcile this with Walter's comment "The GC has been
>> pretty heavily tested. It's 6 years old, and it's stood up extremely
>> well."
>> --(digitalmars.com digitalmars.D:43916)
>
> The problem is that if the data isn't typed, the GC cannot say
> absolutely that the data is not pointers into the GC allocated space.
See my other post. So long as the user doesn't try to pack pointers
into a byte array or something similar, simply using element size can
rule out a significant portion of GCed memory. At the very least, char
strings would be ignored.
> Now in the case of arrays, I think that probably the current collector
> is being far too conservative. Since each array is typed, with the
> exception of void[], the GC should differentiate between, for example, a
> byte[] and a Class[] or void*[] and treat them appropriately.
The type isn't currently available in the compiler runtime or GC code,
but element size is. Passing in a TypeInfo object for allocations may
be a bit more specific, but I'm not sure the additional complexity would
be worthwhile. I suppose it depends on the application.
Sean
More information about the Digitalmars-d
mailing list