How to free resources?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Alex_Sibilev
Posted On:   Sunday, March 2, 2003 04:06 PM

Hello All, I'm novice in Java and trying to write a midlet for by phone. The application I'm writing is accessing quite big array of strings. I defined this array in a separate class public class eData { public String[][] arrData = { {"1","data 1"}, {"2","data 2"} } }; But because this array is quite big it doesn't fit in memory. So I've splitted data into 2 parts and store the second part in different class eData1. In application I'm accessing this array: eData ed = new eData(); .... // accessing array ... ed = null; eData1 ed1 = new eData1(); ....    More>>

Hello All,

I'm novice in Java and trying to write a midlet for by phone.
The application I'm writing is accessing quite big array of strings. I defined this array in a separate class

public class eData {
public String[][] arrData = {
{"1","data 1"},
{"2","data 2"}
}
};

But because this array is quite big it doesn't fit in memory. So I've splitted data into 2 parts and store the second part in different class eData1.

In application I'm accessing this array:

			
eData ed = new eData();
....
// accessing array
...
ed = null;

eData1 ed1 = new eData1();
....



But application crushes with "Out of memory error on line where I'm creating eData1. And if I look what classes are loaded at that time - the eData is still in memory. Is there any possibility to unload the first class to free up memory?
I've tried to put System.gc() after ed=null but it made no difference.

I would appreciate any help on this one.

Alex    <<Less

Re: How to free resources?

Posted By:   Igor_Maznitsa  
Posted On:   Thursday, March 6, 2003 11:07 AM

I use the below code for free resources

Object p_object = smth;


p_object=null;


Runtime.getRuntime().gc();

About | Sitemap | Contact