Garbage collector memory leak "feature"?
Steven Schveighoffer
schveiguy at yahoo.com
Wed Oct 10 10:08:09 PDT 2007
"0ffh" wrote
> Steven Schveighoffer wrote:
>> "0ffh" wrote
>> But why should the GC have to worry about pointers in random data? My
>> question is, is there a *need* for the GC to assume any data could be a
>> pointer, does any code actually *depend* on that behavior? I really
>> would like to see an example of where it is necessary.
>
> Well, we are not just talking about random data, but of data which is
> excplicitly defined as "data of random type, including pointers".
> It is a feature, not a bug; and not incidentally, but planned this way.
OK, I understand it is planned this way. I even understand the rationale
behind it. But this is more of a "functions as designed" feature than a
real feature. I'm sure the writer of the GC did not intend for this side
effect to occur.
I think we are way off track here. There is a problem with the garbage
collector in that it can assume data that is not a pointer is a pointer, and
therefore not collect the data pointed to when it should. It may be that
not scanning void[] is not the solution to the problem, but there is
definitely a problem.
Maybe the solution is for data to have the type information instead of the
pointer type containing the type information. What I mean is, even though
it is a void *, it points to some data. If the type of that data is stored
with the data, then you can tell if the pointed-to data has pointers in it,
regardless of the fact that the type is void.
Maybe there is another solution.
All I know is that if it's going to leak memory for no good reason that I
can see, then I don't want to use it in a production-quality product,
because not only is it impossible to tell whether it will leak data (note
that this problem is completely non-deterministic), but it is impossible to
FIX the problem without significantly paranoid code. And oh by the way I
need to see all the source code to all libraries I use so that I don't
accidentally use something that contains a void *.
-Steve
More information about the Digitalmars-d
mailing list