Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Why "Out of Memory Errors" for this code?  RSS feed

 
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How could this code is executed as part of a thread run out of memory? Here is the info that I have. It runs as part of a thread. So I can see if too many threads are open at once. That is not the case. Also, before I added those close statements, we would see a message on Linux that said it ran out of file descriptors. I have not been able to get in touch with the sys admin for the box to see if that is still the case.

Anyone see anything in this code, that could be causing a problem?



private void initializeRatingEngine(String jarfile)
throws FileNotFoundException
{

RuleBaseLoader loader = new RuleBaseLoader();

FileInputStream rulesjar = null;
JarInputStream js = null;

try
{
if (jarfile == null)
{
rulesjar = new FileInputStream("ratingrules.jar");
js = new JarInputStream(rulesjar);
}
//System.err.println("JAR:"+ jarfile.getAbsolutePath()+" "+
// jarfile.exists());
else
{
rulesjar = new FileInputStream(jarfile);
js = new JarInputStream(rulesjar);

}
loader.loadJar(js);
engine = RatingEngine.getInstance(loader);
rulesjar.close();
js.close();
//System.err.println("LOADED: #countries:"+
// engine.getNumCountriesSupported() );
}
catch (FileNotFoundException ex)
{
logger.error("Error initializing the rating engine: "
+ ex.getMessage());
ex.printStackTrace();
//engine = RatingEngine.getInstance(loader);
throw new FileNotFoundException();
}
catch (Exception ex)
{
logger.error("Error initializing the rating engine: "
+ ex.getMessage());
System.err.println("EX:" + ex);
ex.printStackTrace();
engine = RatingEngine.getInstance(loader);
}
}
 
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you determine which line is throwing the error? Usually you will get a stack trace, however with an OutOfMemoryError it's possible you won't. However you could insert some more print statements between the existing lines of code, and then by looking at the output just before the OOME you can determine where you were in the code.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!