views:

376

answers:

2

Hi All,

Is there any tool to know how many native memory has been used from my java application ? I've experienced outofmemory from my application : Current setting is : -Xmx900m

Computer, Windows 2003 Server 32bit, RAM 4GB.

Also is changing boot.ini to /3GB on windows, will make any difference? If is set Xmx900m, how much max native memory can be allocated for this process ? is it 1100m ?

A: 

If you use for example jvisualvm ( it's shipped with jdk ) you can see how much memory your application is using, you can also profile it more detailously.

Luno
hi Luno,jvisualvm only provide me free and used heap memory, what i need is free native memory. I'm running out of native memory.
Adelave
A: 

The free process space is a bit smaller than 2GB - Xmx. (assuming Sun JVM) You have to add your permgen space to Xmx, and then subtract around 150-200MB or so for the OS's Kernel stuff. If the real problem is a genuine lack of memory, the 3GB switch or reducing your Xmx and PermGen space should alleviate it. Sometimes, at least on Windows, the OS just takes longer than the JVM is willing to wait to allocate a thread and the problem is more that you're spamming thread spawns than running out of memory. You should have memory space for a few thousand threads. How many do you have before it gives up?

There's also a -Xss switch to control how big a thread stack the JVM asks for. YMMV if changing it actually does anything on Windows or not.

Affe
So you are saying to know maximum native memory space is : 2GB - Xmx - Xmx permgen space = Max native memory space.Is changing to 3GB will expand native memory space also? so it become :3GB - Xmx - Xmx permgen space = Max native memory space.Is there any tool to monitor this realtime, afaik i can't find this figure in jconsole/jvisualvm.many thanks.
Adelave
Process explorer will give you some fairly detailed information:http://technet.microsoft.com/en-us/sysinternals/bb896653.aspxThe deep internals of windows memory management are complicated. I don't know if there even exists a simple formula for getting an 'exact' number for how much space you really have free at any given time. Basically you put the app server under production load and tune down the heap until you find the spot where you get neither No Native Threads nor Out of Heap Space.
Affe