Tuesday, March 20, 2007

Dev : Increasing Heap Size Memory

Ever been in a situation where when you try to compile your projects, and all in a sudden, out of memory error occurs. Funny, I have sufficient memory on my pc, but what could have gone wrong? My task manager was showing low memory usage.

This probably could be caused by the heap size memory setting. Most setting, by default, is low. So how do we increase this so call memory? I have been using netBeans and Eclipse IDE for my development. So what I known of is in netBeans and Eclipse only.

Lets say we would like to increase the size to a minimum of 128Mb and maximum 256Mb,

In netBeans,

  1. Go to projects tab.
  2. Locate the project you wish to change the heap size, expand it.
  3. Look for a folder call nbproject.
  4. In nbproject, open the file called project.property.
  5. Locate a line in the file called "runmain.jvmargs=".
  6. Add in parameters. Make it "runmain.jvmargs= -J-Xms128m -J-Xmx256m".
  7. Save the file and rebuild your classes.

In Eclipse,

  1. Go to Package Explorer.
  2. Locate the project you wish to change the heap size, right click it.
  3. In the menu, find Run As > Run... .
  4. A new windows will pop up. Go to the Arguments tab.
  5. In VM Arguments text box, Add in parameters"-Xms128m -Xmx256m".
  6. Click Apply and rebuild your classes.

1 comment:

Anonymous said...

Boring leh.... talking about "Matrix Code" again