Results 1 to 11 of 11
- 02-24-2012, 03:03 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 6
- Rep Power
- 0
Memory is not getting released on RHEL Linux Closely related to Java application
when I put load of 200 users on basic Airthmetic example page that gets shipped with Tomcat. Via free -m command on Linux, I can see the memory consumption (2gb of memory is consumed outta 4gb).
But as soon as the load on page is reduced and if nobody is using that application ..the free -m doesnt show the boost in free memory it still shows memory is occupied and its gradually @ slow pace its showing increase in free memory. I am not able to get this behaviour ..Only when I stop my tomcat it shows the actual good Available memory i.e approx 4gb. please suggest some settings
I wanted to know when my actual Webapplication with DB connectivity in Linux gets Live and is used by 200 users. Memory issue will affect its performance ..!
- 02-24-2012, 03:13 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Memory is not getting released on RHEL Linux Closely related to Java application
The JVM grabs the memory off the underlying system.
It does not release that memory back except very slowly (there was a time it never released it back).
When you start a JVM up you tell it how much memory it is allowed to use (-Xmx, or the default) and therefore it can use up to that amount. If you have assigned it 2Gb of avaiable memory, then don't be surprised when it takes that and keeps hold of it.Please do not ask for code as refusal often offends.
- 02-27-2012, 05:52 AM #3
Member
- Join Date
- Feb 2012
- Posts
- 6
- Rep Power
- 0
Re: Memory is not getting released on RHEL Linux Closely related to Java application
Thanks Tolls for your reply....
We haven't assigned any memory to JAVA_OPTS or CATALINA_OPTS in catalina.sh. We are using the default catalina.sh.
Its still consuming that much amount of memory mentioned above and releasing very slowly.
- 02-27-2012, 11:21 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Memory is not getting released on RHEL Linux Closely related to Java application
There's a default value for the JVM based on the assumed type of machine you are using.
In your case probably a server (these days that tends to be the case as it's based, I think, on number of processors).
That default is usually around 1Gb, but that might have changed.
If this is a live server you should specify the amount you want to give Tomcat (and associated webapps).
Anyway, whatever you end up specifying then the JVM will quite likely grab that at some poiont and only slowly release it, as you are currently seeing.Please do not ask for code as refusal often offends.
- 02-29-2012, 09:44 AM #5
Member
- Join Date
- Feb 2012
- Posts
- 6
- Rep Power
- 0
Re: Memory is not getting released on RHEL Linux Closely related to Java application
Hi Toll,
Thanks for your valuable time and the knowledge you have shared on the forum. Would like to know whether is there anyway using which we can expedite the release. Thanks.
Regards,
AjayLast edited by arajendran; 02-29-2012 at 11:15 AM. Reason: New to Forum Group
- 03-03-2012, 12:49 PM #6
Member
- Join Date
- Feb 2012
- Posts
- 6
- Rep Power
- 0
Re: Memory is not getting released on RHEL Linux Closely related to Java application
here's One more scenario
I created a webapplication via Eclipse with only one jsp i.e index.jsp. In this jsp page.. I have only typed in "just a Jsp" inside Body tag nothing else and I exported a war and deployed it to tomcat. Now I asked my Software tester colleague to just put a load of 200 users on this jsp ..During the load I was monitoring memory via free -m command
here's free -m the output
.................................................. .............................
On Tomcat Start
1)
-/+ buffers/cache: used 251 free 3697
.................................................. .............................
Below is the memory status when the load was complete
3)
-/+ buffers/cache: used 1727 free 2221
.................................................. .............................
below is when the Load was Completed and after few mins memory status is still :(
-/+ buffers/cache: used 1723 free 2225
the used 1723 never reduces !!!!!
For my real Web application I've been asked such Question .. will the consumed memory ever reduces?
In btw the load.. when I fired the command ps aux it showed 41 % memory consumed by java ...Can Somebody please help me on this ?
ps: for 200 users to work we have set xmx and xms value to 1536m (coz it wasnt taking the default value, 1024m or just 512m and load was failing) load worked successfully with xmx and xms value to 1536m
*Environment*
Red Hat Linux
JDK1.6
Tomcat6
4g RamLast edited by arajendran; 03-03-2012 at 12:53 PM.
- 03-03-2012, 02:33 PM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
Re: Memory is not getting released on RHEL Linux Closely related to Java application
Operating systes are kind of stupid when it comes to memory allocation and releases, i.e. they treat memory as a stack; they can give more memory from the top of the stack and it has to be given back to the OS so that it fits on that stack top again. See the man pages for the brk and sbrk calls. If a process has free memory somewhere 'in the middle' it can't release it to the OS because it has to be a consecutive chunk with the memory on the stack. The JVM shuffles memory around and when/if a 'feasible' chunk of free memory becomes avaalable it can be returned to the OS. The trouble here is that only the garbage collector can check this but if the Java process doesn't do anything the garbage collector isn't invoked and no possible memory can be returned to the OS. The advantage is that this memory can be reused by the Java process without any system calls where the Java virtual machine has to beg for more memory from the OS but the disadvantage is that the JVM is using 'too much' memory at a certain moment in time. The other advantage is that we're talking virtual memory here.
kind regards,
JosLast edited by JosAH; 03-03-2012 at 02:36 PM.
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-05-2012, 11:26 AM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Memory is not getting released on RHEL Linux Closely related to Java application
And?
I don't see the problem.
If you'd given the application a hundred Mb then you'd get some garbage collection going on, but you gave it lots such that it never had to do a gc in the time you were monitoring it.
Either your application fits on the server or it doesn't.
Either your server has the memory to support your application or it doesn't.
So what is the problem with Java occupying the memory you have allocated to it?
It's not as if anything else is using it...Please do not ask for code as refusal often offends.
- 03-06-2012, 06:10 AM #9
Member
- Join Date
- Feb 2012
- Posts
- 6
- Rep Power
- 0
Re: Memory is not getting released on RHEL Linux Closely related to Java application
Thanks JosAH for your reply ..yes! memory is getting reused for subsequent load of 200 users.
- 03-06-2012, 06:17 AM #10
Member
- Join Date
- Feb 2012
- Posts
- 6
- Rep Power
- 0
Re: Memory is not getting released on RHEL Linux Closely related to Java application
Thanks Tolls..my application was not taking load of 200 users ..the tests were failing ..only when I increased the heap size ..it passed successfully. My prob was the java occupying memory is there but will it release ever!! I waited hours to see ..also we went on looking for some kinda parameters that shall help to free the used memory :P
nothing so far we've found ..but we observed that on subsequent loads.. its getting re-utilized :)
- 03-06-2012, 09:42 AM #11
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Memory is not getting released on RHEL Linux Closely related to Java application
Of course it is.
That memory is memory the OS has given the JVM to use.
That is the JVMs Heap (+ other bits).
You need to understand that the JVM is simpyl an application sat on top of the OS.
It manages its own memory, which is a great slab of memory from the OS.
You don't use OS-related memory commands to see what memory your app is using, you use JVM-related memory commands (profiling, heap monitoring, that sort of thing).
There is no reason to have the JVM release memory back to the OS, frankly.Please do not ask for code as refusal often offends.
Similar Threads
-
setup related problem on Java Desktop Application
By ravi.iise08@gmail.com in forum Advanced JavaReplies: 1Last Post: 10-25-2011, 06:03 PM -
getRuntime().exec(run) in Linux. a path related problem?
By AndyVidk in forum Advanced JavaReplies: 10Last Post: 10-10-2011, 09:33 AM -
Idle Java Application - Memory Leak? (JCONSOLE)
By icesnake in forum New To JavaReplies: 6Last Post: 06-12-2010, 09:00 AM -
Out of memory work around for a java application (please help!)
By javameanslife in forum Advanced JavaReplies: 9Last Post: 02-02-2010, 01:52 PM -
Error: Can't run as an application since it use sound-related methods
By mathias in forum New To JavaReplies: 1Last Post: 08-07-2007, 06:45 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks