Loginskip to content

November 1st, 2006

information from inside a script, or if your

information from inside a script, or if your topis restricted for root’s use only, use the psprogram to get information about the process numbered pid. On SYSVish systems, use ps-lp pid; on BSDish systems, use psupid. (You can usually use a repeated -wflag on SYSV or a w flag on BSD to see more of the command column if it is truncated.) In each case, there are two columns labeled SZ(or VSZ) and RSS. Roughly speaking, these are, respectively, the total virtual memory in use by the process and the amount of physical memory in use, both in kilobytes. Note that the amount of memory allocated by a Unix process never decreases before it terminates; whenever it frees memory it makes it available only for the same process to reuse again later. (It is not returned to the free pool for other processes to use.) A very large and lengthy program of mine that reports its girth hourly has just displayed USER PID %CPU %MEM SZ RSS TT S START TIME COMMAND peter 28679 51.9 48.5 35248 30072 ? S 08:42:02 279:33 [truncated] which shows that its total memory usage is 35 MB, 30 of which are in physical memory. (The output was doctored slightly since the columns output by ps had actually run together.) Because it has had problems with running out of memory, this provides periodic statistics that tell me what it really uses. If you want to monitor the progress of your own Perl script, use $$ in place of pid: printf “Current virtual memory: %skn”, unpack ‘@24A5′, (`ps u $$`)[1]; (The actual unpack template you have to use may be different for your ps. By using a subscript on the backticks in list context, we can ignore the header line output by ps.) You can use ps like this to see the actual amount of memory used by your program as it executes. (And remember that on Unix, process sizes never decrease, no matter how much memory you free in your program. Your process will never get smaller than its largest memory allocation.) Under MacOS, access “About This Computer” from the Apple menu. A graphic displays the allocated memory per process and the fraction used (see Figure 11-1). Figure 11-1. Memory usage under MacOS
Note: If you are looking for reliable and quality webspace company to host and run your servlet application check Actions servlet hosting services

Comments are closed.