I built a program and its size is increasingly becoming large. In order to avoid running out of heap memory later, I want to carefully define any variables inside my classes.
But before this, I want to clarfy one thing first, which is, local variables are stored on the stack; instance variables are stored on the heap. -- someone please check this statement's correctness.
If what I wrote above is right, is it a good way to define more local variables and less instance variables would make my program consume less memory? Is it a good way to define more StringBuffer variables instead of String variables so that there are less number of objects are created by JVM, which results in less memory consuming? What else technique could we do in order to minimize heap space?
Thanks
[ December 01, 2005: Message edited by: reubin yi ]
But before this, I want to clarfy one thing first, which is, local variables are stored on the stack; instance variables are stored on the heap. -- someone please check this statement's correctness.
If what I wrote above is right, is it a good way to define more local variables and less instance variables would make my program consume less memory? Is it a good way to define more StringBuffer variables instead of String variables so that there are less number of objects are created by JVM, which results in less memory consuming? What else technique could we do in order to minimize heap space?
Thanks
[ December 01, 2005: Message edited by: reubin yi ]