It depends. Perl will 'free' values when there are no more references to them. That means Perl has to access to those
values, possible 'free' associated structures, and even
cascading the 'freeing' of variables. This could mean accessing recently accessed memory (for instance, a lexical
variable in a small loop), which might be found in cache.
It could also mean accessing 'old' values (for instances,
modifying a long living object), which means Perl might have
to access whatever is swapped out.
I expect this to be the case in almost any language that does garbabe collection. If you collect your garbage at one moment, and you have swapped, the act of collecting the garbage will cause a swap.
What's the lesson to be learned here? Don't swap. Invest in
more memory.
Abigail | [reply] |
Perl 5 doesn't have a traditional garbage collector. It uses reference counting and so doesn't need to visit every single item periodically as part of checking if it is still being referenced.
Perl 6 will suffer from this problem but Perl 5 doesn't.
| [reply] |
| [reply] |
Yes, it's a Parrot thing.
It's possible that something like a generational GC can "cycle" slowly enough that the pages to be swapped in can be controlled and
even anticipated. Also, a compacting GC will potentially run in a smaller footprint than Perl 5. (Though I think it was decided recently that a compacting GC was incompatible with threading in Parrot, if I recall.)
But I agree with Abigail. If you're running a server, real memory almost always outperforms virtual memory. And with 64-bit computing coming online, there's really no limit to the amount of memory you can add now, apart from arbitrary limitations of particular hardware architectures that chintz out on giving you all your address lines...
| [reply] |
By the way I guess it's a Parrot thing. So all other languages run on Parrot will suffer as well?
No, it's not a parrot thing, and tye's wrong on this. A sweep for dead objects only touches the object header arenas and those areas of the heap that belong to active objects and can contain pointers to other object headers. Those memory areas are generally segregated from the areas of the heap that contain non-pointer data such as strings.
| [reply] |
Perl doesn't really have a garbage collector. It uses reference counting and frees memory when nothing has a reference to it. This does work better with swap because there is no process that scans all the memory looking for unused memory to free.
Perl does not return memory to the OS once it has been freed. It does do a good job of reusing memory, so it is possible to have pages swapped out with only free space or unused data.
| [reply] |