
Achilleas Margaritis escribió:
AFAICS, you can have an implementation of delete where "delete p" simply calls the destructor of the object pointed to by p and then passes p to an internal garbage collector that will reclaim the memory in due time. This way you have determinstic resource liberation *and* GC speed.
If you do that, what is the point of keeping the memory occupied by 'p' around? the object will be destroyed anyway and therefore it will not be of any use.
The point is that deferring memory release to the next GC round can be faster than releasing every little piece of memory immediately, at least in some scenarios: http://www.hpl.hp.com/personal/Hans_Boehm/gc/#details Take into acount that free(x) is by no means free in terms of execution time (no pun intended) --some bookkeeping has to be done by the internal memory manager when freeing a block of memory. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo