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 › memory problem
Page Index Toggle Pages: 1
memory problem (Read 336 times)
memory problem
Jul 20th, 2006, 10:13am
 
I have two questions which, I think, are related with each other.

Q1.
I am working on a Window XP platform with 1G RAM and my program run very slowly. I have read the "out of memory" section in faq before and added the following code in preference.txt:

run.options=-Xms128m -Xmx1024m

I don't know if I can make it run faster by further increase the memory. If I can, then how to re-write the above code? Can I try something like:
 run.options=-Xms256m -Xmx1024m  or
 run.options=-Xms1024m -Xmx1024m  or even
 run.options=-Xms1024m -Xmx2048m
How can I fully use my 1G RAM?

Q2.
My program become slow after I use array with length of 2 to store the new and old data in time t and t-1 and continuously swap their role of being a new/ old data in every loop of draw(). The basic structure of my program is like this:

myClass[][] myValue;
int current=0;
int next=1;

void setup()
{
 ...
}

void draw()
{
 for (i=0; i<900; i++)
   for (j=0; j<208; j++)
   myValue[i][j].water[next]=myValue[i][j].water[current] + ....;

 if (current==0) {current=1; next=0}
 else {current=0; next=1}
}

class myClass
{
 float[] water;
 
 myClass()
 {
   water = new float[2];
   water[0]=0.0; water[1]=0.0;    
   .......
 }
}

Before that, I just simply initialized "water" as float and updated it by replacing its original value. i.e.
myValue[i][j].water=myValue[i][j].water + ....;
It ran fast and totally ok. However after I use the swapping approach it become slow very obviously and make me surprise.

Does anyone know why? Can this simply be solved by increasing the memory or it is actually an error?










Page Index Toggle Pages: 1