Jump to content
  • Advertisement
Sign in to follow this  
CProgrammer

java heap space

This topic is 4754 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I keep getting java heap space OutOfMemory Exceptions. How can I tell java to use more heap space using eclipse. Furthermore im wondering wether there is a way to explicitely tell java to free memory like c++'s delete keyword.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by CProgrammer
I keep getting java heap space OutOfMemory Exceptions. How can I tell java to use more heap space using eclipse.

You use the normal argument for setting max heap size: -Xmx128M, for example, will set the max heap size to 128MB. In eclipse, I believe you can enter VM arguments in a launch configuration dialog (Run->Run, IIRC). I don't use eclipse, so you'll need to RTFM on that.

Of course, if you have a memory leak, upping the heap size will only delay the inevitable.

Quote:
Furthermore im wondering wether there is a way to explicitely tell java to free memory like c++'s delete keyword.


Not as such. Java gives you almost not control over memory allocation -- the VM handles that for you. On the plus side, the Java GC system is really pretty good since about 1.4.0, and getting better all the time.

One thing that *can* be an issue is holding on to references to objects after you no longer need them. Good design should allow them to go out of scope and/or have all references eliminated naturally, but occasionally it is necessary to explictly null your references. Again, that shouldn't be necessary in well designed code. In my day job I work on a Java app with around 1500 classes and over 200KLOC, and I think we explictly set references to null in perhaps two or three places. I'm personally convinced that those pieces of code are poorly implemented (not my code), though -- like as not those instances could be eliminated, as well.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!