Garbage Collecting
atekippe
Posts: 15
Hello,
I know that the javelin has no means of garbage collecting but does anyone know where I can find information on some solutions to avoid this problem?· No matter what we do in our codes, it errors out·or runs very poorly because of data accumulation. Any help would be appreciated.
atekippe
ISU
I know that the javelin has no means of garbage collecting but does anyone know where I can find information on some solutions to avoid this problem?· No matter what we do in our codes, it errors out·or runs very poorly because of data accumulation. Any help would be appreciated.
atekippe
ISU
Comments
and for global class variables. Single char,byte,short and int are always released once
a method returns. Also try to avoid using String operations (especially adding).
Or use a heap to reclaim space once a variable is no longer needed.
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/peripheral/memory/
regards peter
First thank you for your help earlier.· I've been away from the office for a while and wasn't able to get back on the forums to thank you.· Could you elaborate a little more about how·values·are·released when returning from a method?· I've tried a few little tests to check this and I do not see it being released.· What I'm doing is calling a method, setting an integer and character value, printing those·characters to the screen, then returning to the main program and printing them again.· From what I understand the second time it prints it should be different because the value was released but I'm getting the same thing. Perhaps I'm just missing something simple here.· Thanks for all of your help
atekippe
Globals are declared outside a method and retain their values, whereas locals are declared
inside the method.
example:
public class test {
· static int p = 1; //global variable, retains its value
· static void sample() {
··· int p = 2; //local variable, lost if scope ends
· }
· static void main() {
··· sample(); //call sample() that sets the local p to value 2
··· System.out.println(p); //will print 1, the value of the global p
· }
}
More general, a variable is only known inside the block it is declared.
Example:
for (int p=0; p<10; p++) {
· //p is only known inside the for loop
}
remember, only scalar variables (char, short, byte and int) are automatically released when
exiting a block.
regards peter
atekippe