First, if you want to look more at Windows internals using a Windows app, I would recommend, TaskInfo: http://www.iarsn.com/taskinfo.html. No I don't get any money for this recommendation.
Anyway with TaskInfo you can see how many files and exactly which ones a process has open and details like that which aren't available in the Windows Task Manager (what's paged in/out, etc). Doing advanced things like dynamically lowering the priority of a thread within a process is possible! Whoa!
So anyway on to your question with some code!
I wrote this "quickie" thing...
Run with std Windows TaskManager open and this Perl program in the command window so that you watch both at the same time.
The Windows Task Manager is a bit weird. But this will show a clear spike in memory usage. Then you see the point that the @list has nothing in it anymore, but that won't change windows process usage. Then finally Perl ends and level drops back to what it was before. As Windows background things come and go (like virus software, there are variations, but this @list thing is big enough that the results should be clear.
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my @list;
populate_list(\@list,10000000);
countdown(10);
@list = (); #list has nothing in it now
countdown(10);
sub populate_list
{
my ($lref,$num) = @_;
foreach my $x (0..$num)
{
push (@$lref, $x);
}
}
sub countdown
{
my $num = shift;
while ($num--){sleep(1);print "countdown $num\n";}
}
|