Hi All,
I have never given much thought to memory deallocation with
Perl because I have read in just about every book I own
that Perl handles garbage collection automatically . I've written quite a bit of code with Perl over the past many years but did not really have to be too concerned about MEM usage . I am now working with larger arrays ( LoL's )
and wish to ensure deallocation of MEM but am a bit puzzled now because when I undef the @X array in code below , the system memory is not released . It is only released when the program exits.
I'm using windows , with the Activestate perl binary install.
{
my $i=0 , @X ;
while ( $i < 500000 ) {
push @X , ["a.".$i , "b.".$i , "c.".$i , "d.".$i ] ;
if ($i%10000==0) {printf "Index $i $X[$i][2] \n\n" ;}
$i++ ;
} ;
printf "Max X index Before undef %d\n",$#X ;
sleep 5 ;
undef @X ;
sleep 5 ;
printf "Max X index After undef %d\n",$#X ;
};
sleep 15 ;
Thank you for your insights .
Nova
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.