On Sun, Jun 26, 2005 at 01:42:40PM +0200, Tels wrote: > Example with bleadperl (because there "use vars" doesn't load Carp): > > # ./perl -Ilib -Mvars -le 'print $Carp::VERSION; sleep(1000)' > > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND > 29700 te 17 0 4272 1628 1296 S 0.0 0.2 0:00.00 perl > > #./perl -Ilib -Mvars -MCarp -le 'print $Carp::VERSION; sleep(1000)' > 1.04 > > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND > 29702 te 17 0 4404 1720 1328 S 0.0 0.2 0:00.00 perl > > The lines are from top and you can see that there is a big difference in > memory: > -132 -92 -32 Kbytes
I think this is a bit misleading. The big leap in memory is due to the coarse-grained allocation policy of the system malloc() . You can see a similar effect here: $ ./perl -e'@a=(1..1);system"ps -flp $$"' F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD 0 S davem 19964 20069 0 76 0 - 1381 wait 12:57 pts/7 00:00:00 ./per $ ./perl -e'@a=(1..126);system"ps -flp $$"' F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD 0 S davem 19960 20069 0 76 0 - 1381 wait 12:56 pts/7 00:00:00 ./per $ ./perl -e'@a=(1..127);system"ps -flp $$"' F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD 0 S davem 19962 20069 0 76 0 - 1414 wait 12:56 pts/7 00:00:00 ./per gradually increasing the size of the array has no effect on process size until suddenly the system malloc() grabs an extra 33x4096 = 132K. I saw a similar thing by stripping down Carp.pm: with just the first 3 lines of the file, the process size was unchanged; adding the fourth line (a simple variable declaration), the process size jumped by 132K; adding in the entire remaining body of Carp.pm didn't increase the process size any further. So you can't really conclude anything about Carp.pm's footprint just from examining process size. -- To collect all the latest movies, simply place an unprotected ftp server on the Internet, and wait for the disk to fill....