I have in my Java application a thread that run a while(True) loop with a sleep(50000) (5 minutes) inside. this thread load an XML file before the loop because i need to to parse some information from it in the first iteration.
//Loding XML File
org.jdom.Document document = null;
SAXBuilder sxb = new SAXBuilder();
try
{
document = sxb.build(new File("Configuration/Map.xml"));
}
catch(Exception e){}
org.jdom.Element racine = document.getRootElement();
//End loding XML File
From the 2nd iteration the probability of using the XML file reduce so much, so keeping the XML file in the memory have no sense (since the file have 103,000 line / 3 MB). so i decide to retrieve it from the memory and load it each time i need it.
The problem is that i can’t found how to retrive a document and the racine object from the memory since Java use Garbage collection automatically.
And tell me if this is a good practice to get a optimized solution.
If you only want your object to be garbage collected then I think making the variable Null can do.