I feared as much. Maybe I'll write this thing in C after all.. | [reply] |
C doesn't return freed virtual memory back to
the operating system either. Unless you are running out
of swap space, this shouldn't be of much concern, however.
Now, Perl certainly uses more memory than most things. But
avoiding Perl because some number that "top" reports that
you don't even understand very well might not be the best
application of your time. (:
The two most common measure of memory use are roughly
"virtual memory size" and "working set size". The first
measures (roughly) how much swap space a process requires
while it exists. The second measures (roughly) how much
physical memory the process requires to actually get work
done.
These days, if you are worried about running out of swap
space, then I strongly suggest you configure more swap
space for your system.
If you are worried about your system running slow (because
it wants more physical memory), then you need to look at
the working set size, and that size will go down when the
process stops using the memory that it still has allocated
to its virtual address space (whether the program was
written in C or in Perl).
If you want a process to return memory to the operating
system, then you pretty much have to restart the program.
You can do that easily in Perl with:
exec( $^X, $0, @ARGV );
-
tye
(but my friends call me "Tye")
| [reply] [d/l] |
But, if you follow tye's advice about "exec", keep in mind that (perldoc -f exec):
Note that `exec' will not call your `END' blocks, nor will it call any `DESTROY' methods in your objects.
To avoid weird surprises for long-running programs, I usually let them end "manually" after a period of time and then start/restart them with an endless loop in a shell or batch script.
/J
| [reply] |