|
![](/i/fill.gif) |
Warp <war### [at] tag povray org> wrote:
> It may be possible to explicitly free memory with #undef (I have to admit
> I don't know what #undef does internally), but that's not really related to
> "garbage collection", which is the act of collecting all memory to which
> there is no references anylonger.
As a matter of fact, that's just a modern flavor of what garbage collection
actually describes.
More generally, garbage collection is any act of re-organizing data on a heap in
order to improve various aspects heap performance, most notably (a) total memory
available for allocation, (b) maximum memory available for a single allocation,
(c) performance of memory allocation, and (d) performance of future garbage
collection acts.
Re-claiming "memory to which there is no reference any longer" is only the most
popular aspect of all these, probably because with most programming languages
it is the only aspect on which the programmer has any influence. Everything
else is happening behind the scenes.
Also note that "memory to which there is no reference any longer" is a
misleading description: Even the garbage collector cannot re-claim memory to
which there is no reference any longer. That's the stuff memory leaks are made
of.
A more precise description would be "collecting memory which is no longer
*needed* for the purpose it was allocated for". Some languages require the
programmer to think about and explicitly make known to the GC when a previously
allocated memory block is no longer needed (see free() in C, or dispose in C++),
only some will use reference counters to (attempt to) automatically detect this.
So when invoking #undef, if POV would free() (or disposes) the memory holding
the related object, garbage collection would indeed be triggered.
Post a reply to this message
|
![](/i/fill.gif) |