R. Joseph Newton wrote: > "NIPP, SCOTT V (SBCSI)" wrote: > >> Very interesting... Running this script it dies at the 800MB >> attempt. However, watching this process in top, memory usage is actually >> double the amount that is being tested. In top, the last memory amount >> prior to it dying is 1400MB. >> > > Could be that the data is atctually using only the first 32 bits for each > 64 > allocated. That would mean that it would take twice as much memory to > store the > same amount of data. Gotta get to work. I'll try to expand on this > later. >
another possible explanation is when your program is doing: allocate 100mb memory to $i undef $i allocate 200mb memory to $i undef $i allocate 300mb memory to $i undef $i ... allocate 800mb memory to $i undef $i ... at the end of your program, you are not really only using 800mb of memory. the 'undef $i' statment only tells Perl to free the memory $i is using if there is no other reference to it. it does NOT return the memory back to the os. which means all the memory allocated before the 800mb request are still held by Perl but again this does not neccessary mean Perl is holding 100mb + 200mb + 300mb + ... + 800mb memory though. for example, when your program is requesting 500mb of memory, Perl maybe able to find that by reusing the undef-ed 100mb + 400mb previous allocated so it doesn't have to ask the os for that. the behavior whether Perl will go ask the os for memory or reuse previous allocated is unpredictable and depends on many other factors at the time of the program is running. as a Perl programmer, we have very little control over this behavior. if you must go with this approach, i would trust top/ps whether than what the script output but again, you should research a bit and see if there are tools designed specially for this purpose. the toy-script approach can only get you this far. david -- s,.*,<<,e,y,\n,,d,y,.s,10,,s .ss.s.s...s.s....ss.....s.ss s.sssss.sssss...s...s..s.... ...s.ss..s.sss..ss.s....ss.s s.sssss.s.ssss..ss.s....ss.s ..s..sss.sssss.ss.sss..ssss. ..sss....s.s....ss.s....ss.s ,....{4},"|?{*=}_'y!'+0!$&;" ,ge,y,!#:$_(-*[./<[EMAIL PROTECTED],b-t, .y...,$~=q~=?,;^_#+?{~,,$~=~ y.!-&*-/:[EMAIL PROTECTED] ().;s,;, );,g,s,s,$~s,g,y,y,%,,g,eval -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>