in reply to Understanding garbage collection specifics...
#!/usr/bin/perl use strict; use warnings; show_size(); { my @var=(0..1000000); show_size(); # undef before it goes out of scope undef @var; } show_size(); exit(0); sub show_size { local $/; open(my $pfh, '<', "/proc/$$/status") || die $!; my $size = <$pfh> =~ /VmSize:\s+(\d+)/ ? $1 : 'unknown'; close($pfh); print "Process size: $size\n"; }
Output:
As you can see, a bit of it is left over. Also it works in this simple example, but it may not in big complex scripts, or where objects are involved. </code>Process size: 47936 Process size: 51976 Process size: 48064
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Understanding garbage collection specifics...
by cLive ;-) (Prior) on Feb 01, 2007 at 15:08 UTC | |
by zentara (Cardinal) on Feb 01, 2007 at 16:55 UTC |