2

I have developed a barcode billing and inventory software using netbeans 6.5. I dont know why when the application runs for some time then some times it gives a JAVA Heap stack (Out of Memory) err. I know there is some way to handle the memory allocation in netbeans. Could anyone please help me on this..

Thankx

  • 2
    What's a "Java Heap stack error"? This doesn't seem to have anything to do with the stack. Please be precise in your terminology. – Jesper Aug 09 '10 at 08:03
  • if there is a leak, you could look at http://stackoverflow.com/questions/1473510/general-strategy-to-resolve-java-memory-leak – sly7_7 Aug 09 '10 at 09:17

3 Answers3

2

You need to figure out if your application needs a bigger working memory than the default setting, or if it is just leaking. If there is a memory leak (which is a common problem), then increasing the total memory will only give your application more time before it crashes. It's easy to do (as other posters have suggested) and it will show you if there is a bad leak, so try it first. If it keeps growing in memory, you need to look at what your application is holding onto in memory. Have a look at JConsole (which comes with Java6) or JHat or other tools.

Paul Jowett
  • 6,513
  • 2
  • 24
  • 19
1

You should pass the argument -Xmx1024m when starting your program, so that the jvm can use more heap for your application. This -Xmx will give your programm 1024mb of ram.

Andrzej Doyle
  • 102,507
  • 33
  • 189
  • 228
InsertNickHere
  • 3,616
  • 3
  • 26
  • 23
1

Use java -Xmx<size>m to set the maximum size for the heap. And use a memory profiler like JMP(Java Memory Profiler) to figure out the memory consumption.

Similar questions on SO:

Community
  • 1
  • 1
Zaki
  • 6,997
  • 6
  • 37
  • 53