eclipse - JAVA For Loop running out of memory when running though image files -


i loading 100 fits images of 3000x2000 pixels , converting pixel values each image matrix , rescaling matrix , adding each 1 set.

but running out of memory in heap. set of int matrices shouldn't take memory should it? (the heap 2gb believe, @ least eclipse uses 2gb before giving error.)

so thinking each new fits object being stored in memory after each loop. isn't needed again after loop finishes don't know why case.

is there way without running out of memory? there different number of fits files each time program run.

public set<int[][]> rescalefitslist(file[] fitsfilelist){      set<int[][]> rescaledfitsset = new hashset();       for(file fits: fitsfilelist){          fits f = new fits(fits);          double bscale = f.gethdu(0).getbscale;          double blinear = f.gethdu(0).getblinear;          short[][] counts = (short[][])f.gethdu(0).getkernel();          int[][] rescaledfits = new int[counts.length][counts[0].length];              for(int =0, i<counts.length, i++){                 for(int j =0, j<counts[0].length, j++){                     rescaledfits[i][j] = (int)(bscale * counts[i][j] + blinear);                   }              }         rescaledfitsset.add(rescaledfits);       }  } 

an application started within eclipse has own jre (otherwise system.exit(0) kill eclipse ide) own vm settings (other of eclipse ide). make sure set -xmx in launch/run configuration: run > run configurations...: arguments tab: vm arguments field.

100 images of 3000x2000 1 int (4 bytes) per pixel = 100 x 3,000 x 2,000 x 4 bytes = 2,400,000,000 bytes ≈ 2.2 gb. 2 gb not enough memory, 3 gb should work: -xms3g -xmx3g


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -