Karma police
Karma police

Reputation: 175

How to improve the amount of memory used by Jboss?

I have a Java EE application running on jboss-5.0.0.GA. The application uses BIRT report tool to generate several reports.

The server has 4 cores of 2.4 Ghz and 8 Gb of ram.

The startup script is using the next options:

 -Xms2g -Xmx2g -XX:MaxPermSize=512m

The application has reached some stability with this configuration, some time ago I had a lot of crashes because of the memory was totally full.

Rigth now, the application is not crashing, but memory is always fully used. Example of top command:

Mem:   7927100k total,  7874824k used,    52276k free

The java process shows a use of 2.6g, and this is the only application running on this server.

What can I do to ensure an amount of free memory?

What can I do to try to find a memory leak?

Any other suggestion?

TIA


Based in answer by mezzie:

If you are using linux, what the kernel does with the memory is different with how windows work. In linux, it will try to use up all the memory. After it uses everything, it will then recycle the memory for further use. This is not a memory leak. We also have jboss tomcat on our linux server and we did research on this issue a while back.

I found more information about this,

https://serverfault.com/questions/9442/why-does-red-hat-linux-report-less-free-memory-on-the-system-than-is-actually-ava

http://lwn.net/Articles/329458/

And well, half memory is cached:

             total       used       free     shared    buffers     cached
Mem:          7741       7690         50          0        143       4469

Upvotes: 1

Views: 5680

Answers (3)

Alexis Dufrenoy
Alexis Dufrenoy

Reputation: 11966

To make it simple, the JVM's max amount of memory us is equal to MaxPermGen (permanently used as your JVM is running. It contains the class definitions, so it should not grow with the load of your server) + Xmx (max size of the object heap, which contains all instances of the objects currently running in the JVM) + Xss (Thread stacks space, depending on the number of threads running in you JVM, which can most of the time be limited for a server) + Direct Memory Space (set by -XX:MaxDirectMemorySize=xxxx)

So do the math.If you want to be sure you have free memory left, you will have to limit the MaxPermGen, the Xmx and the number of threads allowed on your server.

Risk is, if the load on your server grows, you can get an OutOfMemoryError...

Upvotes: 1

mezzie
mezzie

Reputation: 1296

If you are using linux, what the kernel does with the memory is different with how windows work. In linux, it will try to use up all the memory. After it uses everything, it will then recycle the memory for further use. This is not a memory leak. We also have jboss tomcat on our linux server and we did research on this issue a while back.

Upvotes: 1

bmargulies
bmargulies

Reputation: 100196

I bet those are operating system mem values, not Java mem values. Java uses all the memory up to -Xmx and then starts to garbage collect, to vastly oversimplify. Use jconsole to see what the real Java memory usage is.

Upvotes: 1

Related Questions