On Sat, Apr 06, 2013 at 09:11:55AM -0400, David Larochelle wrote:
> Are languages that have mark and sweep garbage collection better about
> returning memory to the system than languages like Perl that use reference
> count garbage collection.

Not usually.  On Unix systems, at least, memory is acquired from (and released
to) the system using sbrk. malloc(3) and free(3) are actually front ends to
sbrk. free marks memory as available to be reallocated, but only returns 
memory when there is enough of it at the high end of the heap. Depending
on usage patterns this is unlikely to happen naturally unless memory is first
compacted.

This is an additional step to the garbage collection and not many languages do 
it AFAIK.
I know Lisp can do this, but only to avoid fragmentation and does not return 
the memory.

It is generally not necessary to return memory to the system because
most modern operating systems provide a virtual view of memory so every
program appears to have access to the entire memory space. Most of the time
this works fine. Programs that allocate too much get swapped out when
necessary. If you don't want that for your program, you can always use
mlock(3) and friends.

-Gyepi

_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to