in reply to Re: Re: memory usage woes
in thread memory usage woes

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")

Replies are listed 'Best First'.
Re: (tye)Re: memory usage woes
by jplindstrom (Monsignor) on Nov 22, 2001 at 17:52 UTC
    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