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";} }

In reply to Re^5: Memory management by Marshall
in thread Memory management by abubacker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.