Don't ask to ask, just ask | |
PerlMonks |
Re^2: releasing memory from a loop in Windowsby BrowserUk (Patriarch) |
on Aug 08, 2006 at 01:52 UTC ( [id://566044]=note: print w/replies, xml ) | Need Help?? |
Under some circumstances, Perl (AS) under Win32 will release memory back to the OS. To demonstrate this, in the following snippet 'tasklist.exe', an MS executable, is used to query the OS for the current memory allocation for the current perl process before and after the allocation of a 100 MB chunk of memory, and again after the Perl scalar containing that memory is undef'd:
At startup, the perl executable is using just under 3 MB of ram. After the allocation of 95.36 MB (100 * 1e6) of memory to a Perl scalar (via a ramfile), the memory allocated to the executable stands at just over 101 MB. After the ramfile is closed and the variable $ram is undef'd, the memory allocated to the process falls back to just over 3MB. This occurs because, under Win32, large allocations of ram are allocated and freed using calls directly to the OS. See win32\vmem.c. Specifically, the freeing of memory allocated to the process back to the OS occurs in the following destructor (~ Vmem.c:510 in the source tree):
See MSDN for further information on the operation of this and related OS apis. Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section
Seekers of Perl Wisdom
|
|