in reply to memory leak

Besides all the other typos and anomolies in your code, the main reason your blowing your memory is because of this line:

for($i = 0; $i < $sampleSize; $i++){

At the top of the program you are making this a reference to an anonymous hash:

$sampleSize={}; # This will hold the sample size for each population

But in the for loop you are using the numeric value of that hashref as the upper bound of your loop.

As the numeric value is likely to be something like 26596960, that means that your loop is going to try and create an array of 26 million elements, which would occupy at least 600 MB, for every element in @total.

Your program code makes no sense.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

Replies are listed 'Best First'.
Re^2: memory leak
by Juba (Initiate) on Aug 04, 2004 at 16:03 UTC
    Thanks, this is actually just a slice of the code. It works anyway. You were right, I just needed to use $sampleSize{$currentPop} instead of $sampleSize and it worked. Thanks again.

      I wish I could say "if you were using use strict; use warnings; it would have picked this up", but I can't because it wouldn't have.

      None the less, it would be a good idea anyway :)


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon