tags:

views:

329

answers:

3

so I think I increase my heap size to 1 GB in netbeans, I changed the config to look like:

netbeans_default_options="-J-Xmx1g ......

I closed and started up netbeans again, can I be sure that my app is given 1GB now? or is there a way to verify this?

+2  A: 

You can use jconsole (standard with most JDKs) to check heap sizes of any java process.

disown
This includes real-time charts of memory usage, threads and classes. very useful.
vkraemer
+7  A: 

Use this code:

// Get current size of heap in bytes
long heapSize = Runtime.getRuntime().totalMemory(); 

// Get maximum size of heap in bytes. The heap cannot grow beyond this size.// Any attempt will result in an OutOfMemoryException.
long heapMaxSize = Runtime.getRuntime().maxMemory();

 // Get amount of free memory within the heap in bytes. This size will increase // after garbage collection and decrease as new objects are created.
long heapFreeSize = Runtime.getRuntime().freeMemory(); 

It was useful to me to know it.

Drewen
You will need to recompile your app (NetBeans) if you use this strategy.
vkraemer
+1  A: 

Attach with jvisualvm from Sun Java 6 JDK. Startup flags are listed.

Thorbjørn Ravn Andersen
visualvm... no j
vkraemer
the binary is named jvisualvm(.exe). No idea why.
Thorbjørn Ravn Andersen