We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › stubborn "out of memory"
Page Index Toggle Pages: 1
stubborn "out of memory" (Read 2457 times)
stubborn "out of memory"
Apr 27th, 2005, 5:22pm
 
This works on Linux. But it gives OutOfMemory while loading the image files on OS X and Windows XP. Memory adustments (<string>-Xms128M -Xmx256M</string>) were made as per the "out of memory" part of the FAQ (http://processing.org/faq/bugs.html#memory) on all three platforms (an extreme range of values was tried on OS X and XP has mx set to 1024M in the .bat file). The println(imageName) statement shows that almost all the images load before crashing XP or OS X. On XP, if the value of numFrames is reduced to about 150, the program will load the images and start running draw(), but after the value of dataIn changes a few times, it crashes with OutOfMemory. Images are 19.8 KB 320x240 for a total of about 5 Megs.

I'm happy to make changes and report back the results.

If I hadn't tried the program on Linux first, I would never have believed it would have worked. I think these days they're calling that sort of thing "ironic".


int firstFrame = 3120; //last part of jpg file name
int currentFrame = 0;
int numFrames = 256;  // The number of frames in the animation
PImage[] images = new PImage[numFrames];
  ...
setup(){
  ...
     size(320, 240);

     for(int i=0; i<numFrames; i++) {
           currentFrame = firstFrame + i;
           String imageName = "kew_0000" + currentFrame + ".jpg";
           images[i] = loadImage(imageName);
           println(imageName);
     }
  ...
}

draw(){  
  ...
     dataIn = client.read();
     image(images[dataIn], 0, 0);
  ...
}
Re: stubborn "out of memory"
Reply #1 - Apr 27th, 2005, 7:33pm
 
Just because the images are 19.8K when they're .gif files, doesn't mean they're that small when you load them.
320 * 240* 4bytes/pixel is 307Kb.
So 150 images is 46,080,000 bytes.
Re: stubborn "out of memory"
Reply #2 - Apr 27th, 2005, 10:55pm
 
... Which is about 43.9 MB, plus some for other data associated with each PImage. Perhaps it would be better to losslessly put them into a movie file (QuickTime Pro can convert the sequential images into a lossless video file in one step) and then use the Video library to access each frame.
Re: stubborn "out of memory"
Reply #3 - Apr 28th, 2005, 2:13am
 
I wish the choice of approach were arbitrary, then the QT method _would_ be the best approach. In the department where I work we have two flavors of labs: Mac and Linux. As a demo for a piece of hardware I'm working on which interacts with Processing, I wanted control a real image animation in a way that was portable and cross-platform. There is no Linux support for QT on Processing. The demo _does_ work on Linux and performs very well. That's what's so frustrating. I want it to work the same way everywhere.
Re: stubborn "out of memory"
Reply #4 - Apr 28th, 2005, 2:20am
 
is the app running externally (i.e. the coffee cup icon shows up instead of the processing icon in the window when the app is launched?) if so, changing the .bat file won't help, you need to mess with your preferences.txt file as outlined towards the end of the memory section:
http://processing.org/faq/bugs.html#memory

otherwise, who knows.. it's odd that linux deals with it better than osx and xp, though maybe it's just better with memory management. i wouldn't be surprised if it were just a osx problem but since it's on xp too, hm..

as an odd idea, is the bit depth on all the monitors the same?
Re: stubborn "out of memory"
Reply #5 - May 2nd, 2005, 9:12pm
 
That was it. I was changing the memory settings, but not in all the right places. The change which allowed it to work finally was -the Xms128m -Xmx1024m in preferences.txt . It works on Win, Mac, and Linux the same now. Thanks for your patience.
Page Index Toggle Pages: 1