The Artima Developer Community
Sponsored Link

Java Answers Forum
OutOfMemoryException

2 replies on 1 page. Most recent reply: Oct 20, 2005 11:28 PM by Kondwani Mkandawire

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Amit Gupta

Posts: 1
Nickname: ag05
Registered: Oct, 2005

OutOfMemoryException Posted: Oct 20, 2005 9:19 PM
Reply to this message Reply
Advertisement
I was asked this question in one of my job interviews. I dont know the right answer so am putting it out for people to respond.

If you encounter an OutOfMemoryException then how will you be able to narrow the scope of the problem ?

I said use a profiler and see all the usefull stats like how many objects are getting created, how many are getting destroyed etc and figure out the piece of code thats causing the problem. Once you are able to narrow the scope of the problem go through the particular code and look for place where objects are getting instantiated but somehow not getting garbage collected.

To this the interviewer asked if there is a long running suite of test scripts and this error is encountered after 4 hrs since the script started executing then how would you figure out the root cause of the problem ?

I was not able to give a convincing answer for this question.


Bo Zhu

Posts: 3
Nickname: ffkiller
Registered: Apr, 2004

Re: OutOfMemoryException Posted: Oct 20, 2005 11:24 PM
Reply to this message Reply
A good attempt would be to increase your JVM heap size. Of course this solution assumes that your code still requires reasonable amount of memory and doesn't have some infinite loop that goes on forever.

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: OutOfMemoryException Posted: Oct 20, 2005 11:28 PM
Reply to this message Reply
Ouch that's a tough one, what about simply looking at the
error thrown (and running through the classes that are
throwing that error) ensuring that Objects are not
being created in any infinite loop. Alternatively
just allocating the JVM more memory - all these rants
are long shots, but that's the answer I'd give.

Flat View: This topic has 2 replies on 1 page
Topic: Java simple program help needed Previous Topic   Next Topic Topic: Drawing Oval hierarchy with Graphics g or Graphic2D

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use