A question regarding the GC
torhu
no at spam.invalid
Sat Jul 19 20:37:16 PDT 2008
bearophile wrote:
> If I perform a std.gc.malloc(N), the Phobos GC gives me a pointer P, when I perform a std.gc.realloc(x, 0) it frees the memory, so the GC must remember how much N was (or probably its value rounded to the nearest larger multiple of 4, 8 or 16 bytes).
> So given the pointer P, how can I ask the Phobos GC to quickly tell me how much N was? (and I'd like to know how much approximated such N' value is)
> This will allow me to avoid saving that N value again into my data structures, avoiding wasting space to keep N two times in memory.
> If the Phobos GC API is currently unable to give me this N' value and approximations, can't we modify the GC so it can give us such values?
>
Are you aware of std.gc.capacity()? If you want to know what sizes the
GC rounds to when allocating, you probably need to read the source,
which comes with dmd.
More information about the Digitalmars-d-learn
mailing list