You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Robinson, Eric" <er...@psmnv.com> on 2012/02/17 05:58:15 UTC

Free Memory vs. Total Memory vs. Max Memory

What are the possible downsides of setting a low initial memory pool and
a high max pool? If a tomcat app usually needs approximately 64MB of
heap space, but sometimes as much as 300-400MB, would it cause any
problems to set the initial pool to 16M and the max pool to 512M?
 

--
Eric


 


Disclaimer - February 16, 2012 
This email and any files transmitted with it are confidential and intended solely for Tomcat Users List. If you are not the named addressee you should not disseminate, distribute, copy or alter this email. Any views or opinions presented in this email are solely those of the author and might not represent those of Physicians' Managed Care or Physician Select Management. Warning: Although Physicians' Managed Care or Physician Select Management has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments. 
This disclaimer was added by Policy Patrol: http://www.policypatrol.com/

RE: Free Memory vs. Total Memory vs. Max Memory

Posted by "Robinson, Eric" <er...@psmnv.com>.
> You have to balance that against the minimal cost of today's 
> memory (even ECC RAM is under $10 per GiB).
> 

True, RAM is relatively cheap, but servers are not. We like to stack as
many instances of tomcat on a server as possible while maintaining good
performance. Some of our 8-core 32GB servers have had up to 200 separate
tomcat instances. Allowing tomcat to dynamically manage its own memory
(i.e., using a low -Xms value) makes that possible.

--Eric


 


Disclaimer - February 22, 2012 
This email and any files transmitted with it are confidential and intended solely for Tomcat Users List. If you are not the named addressee you should not disseminate, distribute, copy or alter this email. Any views or opinions presented in this email are solely those of the author and might not represent those of Physicians' Managed Care or Physician Select Management. Warning: Although Physicians' Managed Care or Physician Select Management has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments. 
This disclaimer was added by Policy Patrol: http://www.policypatrol.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Free Memory vs. Total Memory vs. Max Memory

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Christopher Schultz [mailto:chris@christopherschultz.net] 
> Subject: Re: Free Memory vs. Total Memory vs. Max Memory

> Okay, so it sounds like if the environment is such that reducing the
> heap at intervals is important (many JVMs, peak-memory-load events are
> rare, etc.) then using Xms < Xmx isn't a bad idea at all.

If the peak-load periods truly are infrequent and of short duration, _and_ you can tolerate the hiccup as the heap ramps up, then yes, having a small minimum heap size would be ok.  It's the ramp-up impact that can really annoy the end users.  You have to balance that against the minimal cost of today's memory (even ECC RAM is under $10 per GiB).

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


Re: Free Memory vs. Total Memory vs. Max Memory

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chuck,

On 2/21/12 1:06 PM, Caldarale, Charles R wrote:
>> From: Christopher Schultz [mailto:chris@christopherschultz.net] 
>> Subject: Re: Free Memory vs. Total Memory vs. Max Memory
> 
>> I'll have to do some more reading about the JVM returning memory
>>  to the OS after the heap shrinks: if the JVM does not return the
>>  memory, then your most-recent peak-heap-size will dictate the 
>> amount of memory your process controls until it it shut down.
> 
> It doesn't really matter if the JVM returns the memory to the OS. 
> Even when not unmapped, the JVM won't try to use it, so the real 
> memory requirements of the process are reduced.  The unused pages 
> will disappear to the swap file if the RAM is needed for something 
> else; this will cause an extremely minor hiccup if the load
> increases and the JVM decides to expand the heap again and the
> pages have to read in (even though the contents are no longer of
> interest).

Okay, so it sounds like if the environment is such that reducing the
heap at intervals is important (many JVMs, peak-memory-load events are
rare, etc.) then using Xms < Xmx isn't a bad idea at all.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk9D32oACgkQ9CaO5/Lv0PCssQCfTRXYxOe+4yiaLuzmsW1vnUB5
064AoKhpKa0H1ObhuKJWVv7pmyz/tSuR
=GcYu
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Free Memory vs. Total Memory vs. Max Memory

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Christopher Schultz [mailto:chris@christopherschultz.net] 
> Subject: Re: Free Memory vs. Total Memory vs. Max Memory

> I'll have to do some more reading about the JVM returning memory 
> to the OS after the heap shrinks: if the JVM does not return the 
> memory, then your most-recent peak-heap-size will dictate the 
> amount of memory your process controls until it it shut down.

It doesn't really matter if the JVM returns the memory to the OS.  Even when not unmapped, the JVM won't try to use it, so the real memory requirements of the process are reduced.  The unused pages will disappear to the swap file if the RAM is needed for something else; this will cause an extremely minor hiccup if the load increases and the JVM decides to expand the heap again and the pages have to read in (even though the contents are no longer of interest).

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


Re: Free Memory vs. Total Memory vs. Max Memory

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Eric,

(Late reply. Sorry.)

On 2/17/12 11:41 PM, Robinson, Eric wrote:
> Recently, we had someone tell us that a particular thread of one 
> particular Windows tomcat instance was freezing up due  to lack of 
> memory. They insisted that we set that instance to -Xms512M
> -Xmx512M.

Wow, that's quite a jump. Obviously a "best practice" they read
somewhere and are making you follow it blindly. Does this "someone"
have any real power? Or, are they a contractor being brought-in to
tell you that your team doesn't have a clue what it's doing? (In that
case, whatever they say usually goes, unfortunately, because you are
already considered wrong at the outset).

> I felt that they were wrong because there were no OOM or GC
> messages in the logs, but I wanted to make them happy, so I set it
> to -Xms16M -Xmx512M because I felt that this would give them the
> max memory they were requesting while also ensuring that the
> instance did not use more memory than it really needed. It seemed
> like a win-win. However, they were not happy. They insisted that we
> set the minimum to 512M as well.

That sounds a little foolish. The only reason to set Xms=Xmx is to
avoid heap re-sizing at runtime. Unless there is a bug in the GC or
memory manager, then there should only be performance differences in
the way Xms=Xmx versus Xms<Xms behaves: the max heap size is still the
same and the JVM won't trigger an OOME unless it's out of space (given
Xmx as well as some other factors that aren't relevant to the heap,
such as PermGen, stacks, etc.).

If you aren't seeing OOMEs, then the problem probably isn't the heap
size at all. Then again, you might not be seeing OOMEs because you're
not looking in the right place.

> My plan was to come onto the tomcat list and see if I could drum up
> support for my thoughts, but I realize that I also risk being told
> that I'm wrong. :-)

We(*) usually recommend that Xms=Xmx to avoid heap re-sizing and
maximize performance. I figure that if you're going to need the
memory, you may as well ask for it up front. I'll have to do some more
reading about the JVM returning memory to the OS after the heap
shrinks: if the JVM does not return the memory, then your most-recent
peak-heap-size will dictate the amount of memory your process controls
until it it shut down. In that case, I would size the heap Xms=Xmx
where both are set to your peak load expectation.

- -chris

* Well, me, and several others on this list. There is no "official"
stance from either Apache or Tomcat.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk9D1kgACgkQ9CaO5/Lv0PAdAQCfUXd8AvfWAvWya7R8RlNMZjXX
AEcAn1yp1eZZRycAH1cIAAeBCNHezjeV
=kQ8j
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Free Memory vs. Total Memory vs. Max Memory

Posted by ma...@apache.org.
"Robinson, Eric" <er...@psmnv.com> wrote:

>Agreed. Anyway, in this case the thread is on a tomcat server that is
>only used for scheduled java tasks. Users do not access it directly.
>Very puzzling. What's I'd really like is for some well-known tomcat
>guru
>to say that in our environment, -Xms16M is fine and that the assertion
>that a low -Xms value could result in memory shortages at runtime or
>thread freezes is silly.

Providing -Xmx is set appropiately and the OS is able to respond promptly when the java process requests more memory then such a statement seems silly. Gc logging is the way to confirm what is happening.

Mark




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Free Memory vs. Total Memory vs. Max Memory

Posted by Mark Thomas <ma...@apache.org>.
On 18/02/2012 14:44, Mark Thomas wrote:
> "Robinson, Eric" <er...@psmnv.com> wrote:
> 
>> Agreed. Anyway, in this case the thread is on a tomcat server that
>> is only used for scheduled java tasks. Users do not access it
>> directly. Very puzzling. What's I'd really like is for some
>> well-known tomcat guru to say that in our environment, -Xms16M is
>> fine and that the assertion that a low -Xms value could result in
>> memory shortages at runtime or thread freezes is silly.
> 
> Providing -Xmx is set appropiately and the OS is able to respond
> promptly when the java process requests more memory then such a
> statement seems silly. Gc logging is the way to confirm what is
> happening.

And a thread dump wouldn't hurt either.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Free Memory vs. Total Memory vs. Max Memory

Posted by "Robinson, Eric" <er...@psmnv.com>.
> Robinson, Eric wrote:
> >> We have many servers that have been running 100-200 instances of 
> >> tomcat each for years without any performance problems.
> >> Most of our servers are Linux 8-core machines with 32GB 
> RAM, with the 
> >> tomcat instances configured with -Xms16M -Xmx192M.
> >> We also have some Windows servers with 100-150 instances of tomcat 
> >> each, most of which are configured with -Xms16M -Xmx64M.
> >>
> > 
> > To add to the above, we see zero swapping and very low 
> iowait (or disk
> > queue lengths in Windows).
> > 
> You would have saved everyone some time by being a little bit 
> more forward with the above.
> Your initial question sounded deceptively beginner-like, 
> which is why you got beginner 
> treatment.

Sorry about that. Regardless of the number of tomcats we run
(approximately 1000) I still think of myself as a tomcat beginner. :-)
Also, I was trying to avoid poisoning the well so I kept the facts to a
minumum.

> 
> Thanks for sharing the data above in any case.  It provides a 
> future reference point for 
> similar enquiries.
> 
> Anyway, it sounds like you have at least the possibility of 
> getting plenty of real-world 
> data to confirm or disprove you thesis.  Just enabling GC 
> logging at the minimum level on 
> that instance should be enough to provide a good impression 
> of what's going on at 
> different settings of Heap size.

I'll do that.

> Unless you also know the exact applications and usage of that 
> instance, you may still be 
> surprised.
> 
> I also administer a number of Tomcat instances, usually 
> running one single and in 
> principle smallish application, always the same, each Tomcat 
> being alone on one of a 
> similar set of (Linux) servers.  In most cases, 128 MB Heap 
> is enough and we never see a 
> problem.  In a couple of cases however, 512MB Heap is the 
> absolute minimum to provide 
> acceptable user-perceived performance.  

Understood. We also have a small percentage of instances that require
384M, and a couple that require 512M. But even with those, I set
-Xms16M. And that's really where I get to the core of my question. In my
view, it only takes a few microseconds for the instance to allocate more
RAM if it is required. I really don't see a downside. More imporetantly,
I don't see how setting a low initial pool would cause a thread to
freeze.

>The difference is not 
> so much in the absolute 
> number of users or requests, but in the pattern of usage 
> during the day.  Our favored 
> hypothesis is that several hundred employees always return 
> from their coffee breaks at 
> exactly the same time.
> Just to say that you never know until you measure.

Agreed. Anyway, in this case the thread is on a tomcat server that is
only used for scheduled java tasks. Users do not access it directly.
Very puzzling. What's I'd really like is for some well-known tomcat guru
to say that in our environment, -Xms16M is fine and that the assertion
that a low -Xms value could result in memory shortages at runtime or
thread freezes is silly. One can hope.

--Eric





Disclaimer - February 18, 2012 
This email and any files transmitted with it are confidential and intended solely for Tomcat Users List. If you are not the named addressee you should not disseminate, distribute, copy or alter this email. Any views or opinions presented in this email are solely those of the author and might not represent those of Physicians' Managed Care or Physician Select Management. Warning: Although Physicians' Managed Care or Physician Select Management has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments. 
This disclaimer was added by Policy Patrol: http://www.policypatrol.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Free Memory vs. Total Memory vs. Max Memory

Posted by André Warnier <aw...@ice-sa.com>.
Robinson, Eric wrote:
>> We have many servers that have been running 100-200 instances 
>> of tomcat each for years without any performance problems. 
>> Most of our servers are Linux 8-core machines with 32GB RAM, 
>> with the tomcat instances configured with -Xms16M -Xmx192M. 
>> We also have some Windows servers with 100-150 instances of 
>> tomcat each, most of which are configured with -Xms16M -Xmx64M. 
>>
> 
> To add to the above, we see zero swapping and very low iowait (or disk
> queue lengths in Windows).
> 
You would have saved everyone some time by being a little bit more forward with the above.
Your initial question sounded deceptively beginner-like, which is why you got beginner 
treatment.

Thanks for sharing the data above in any case.  It provides a future reference point for 
similar enquiries.

Anyway, it sounds like you have at least the possibility of getting plenty of real-world 
data to confirm or disprove you thesis.  Just enabling GC logging at the minimum level on 
that instance should be enough to provide a good impression of what's going on at 
different settings of Heap size.
Unless you also know the exact applications and usage of that instance, you may still be 
surprised.

I also administer a number of Tomcat instances, usually running one single and in 
principle smallish application, always the same, each Tomcat being alone on one of a 
similar set of (Linux) servers.  In most cases, 128 MB Heap is enough and we never see a 
problem.  In a couple of cases however, 512MB Heap is the absolute minimum to provide 
acceptable user-perceived performance.  The difference is not so much in the absolute 
number of users or requests, but in the pattern of usage during the day.  Our favored 
hypothesis is that several hundred employees always return from their coffee breaks at 
exactly the same time.
Just to say that you never know until you measure.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Free Memory vs. Total Memory vs. Max Memory

Posted by "Robinson, Eric" <er...@psmnv.com>.
> We have many servers that have been running 100-200 instances 
> of tomcat each for years without any performance problems. 
> Most of our servers are Linux 8-core machines with 32GB RAM, 
> with the tomcat instances configured with -Xms16M -Xmx192M. 
> We also have some Windows servers with 100-150 instances of 
> tomcat each, most of which are configured with -Xms16M -Xmx64M. 
> 

To add to the above, we see zero swapping and very low iowait (or disk
queue lengths in Windows).

--Eric




Disclaimer - February 17, 2012 
This email and any files transmitted with it are confidential and intended solely for Tomcat Users List. If you are not the named addressee you should not disseminate, distribute, copy or alter this email. Any views or opinions presented in this email are solely those of the author and might not represent those of Physicians' Managed Care or Physician Select Management. Warning: Although Physicians' Managed Care or Physician Select Management has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments. 
This disclaimer was added by Policy Patrol: http://www.policypatrol.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Free Memory vs. Total Memory vs. Max Memory

Posted by "Robinson, Eric" <er...@psmnv.com>.
> >> I can see the lure of "only taking what you need" and allowing the 
> >> JVM to automatically re-size the memory space:
> >> that way, you only take up a huge chunk of memory during peak load 
> >> and not all the time.
> >>
> >> But why?
> >>
> >> If you are going to need, say, 512MiB at peak load, you're 
> going to 
> >> need that memory available whether or not it is allocated 
> to the JVM 
> >> itself at any given time. If that's the case, why not let the JVM 
> >> have that memory all the time?
> > 
> > 
> > Because the server has about 100 instances of tomcat. They 
> do not all 
> > need the memory at the same time.
> > 
> 
> Famous last words..
> 
> But if they ever do, you are going to experience random 
> failures of your Tomcat instances, or at the very least a 
> dramatic drop in performance, when this starts to swap to disk.
> 
> We don't know what your precise circumstances are, and maybe 
> your case is special.
> But in general, I would not recommend this as a way to run a 
> production server.
> 
> Technically, you can do what you described.  What results it 
> will have in the practice, you will find out.
> 

Okay, full disclosure time.

We have many servers that have been running 100-200 instances of tomcat
each for years without any performance problems. Most of our servers are
Linux 8-core machines with 32GB RAM, with the tomcat instances
configured with -Xms16M -Xmx192M. We also have some Windows servers with
100-150 instances of tomcat each, most of which are configured with
-Xms16M -Xmx64M. 

Recently, we had someone tell us that a particular thread of one
particular Windows tomcat instance was freezing up due  to lack of
memory. They insisted that we set that instance to -Xms512M -Xmx512M. I
felt that they were wrong because there were no OOM or GC messages in
the logs, but I wanted to make them happy, so I set it to -Xms16M
-Xmx512M because I felt that this would give them the max memory they
were requesting while also ensuring that the instance did not use more
memory than it really needed. It seemed like a win-win. However, they
were not happy. They insisted that we set the minimum to 512M as well. I
did it but I am annoyed. I don't think my approach is dangerous at all
becaise the time involved in allocating memory and doing GC does not
have a significant impact on performance. My plan was to come onto the
tomcat list and see if I could drum up support for my thoughts, but I
realize that I also risk being told that I'm wrong. :-)

--Eric


Disclaimer - February 17, 2012 
This email and any files transmitted with it are confidential and intended solely for Tomcat Users List. If you are not the named addressee you should not disseminate, distribute, copy or alter this email. Any views or opinions presented in this email are solely those of the author and might not represent those of Physicians' Managed Care or Physician Select Management. Warning: Although Physicians' Managed Care or Physician Select Management has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments. 
This disclaimer was added by Policy Patrol: http://www.policypatrol.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Free Memory vs. Total Memory vs. Max Memory

Posted by André Warnier <aw...@ice-sa.com>.
Robinson, Eric wrote:
>>> If your application 
>> needs 64MB of 
>>> Heap space and you allocate only -Xms16M, then right at the 
>> start the 
>>> JVM will have to increase the Heap to 64MB (minimum); so 
>> why would you 
>>> do that ?
> 
> 64MB was just a number I threw out. The app actually uses about 20MB at
> startup, so we might consider setting the minimum pool to 25M.
> 
>> I can see the lure of "only taking what you need" and 
>> allowing the JVM to automatically re-size the memory space: 
>> that way, you only take up a huge chunk of memory during peak 
>> load and not all the time.
>>
>> But why?
>>
>> If you are going to need, say, 512MiB at peak load, you're 
>> going to need that memory available whether or not it is 
>> allocated to the JVM itself at any given time. If that's the 
>> case, why not let the JVM have that memory all the time?
> 
> 
> Because the server has about 100 instances of tomcat. They do not all
> need the memory at the same time.
> 

Famous last words..

But if they ever do, you are going to experience random failures of your Tomcat instances, 
or at the very least a dramatic drop in performance, when this starts to swap to disk.

We don't know what your precise circumstances are, and maybe your case is special.
But in general, I would not recommend this as a way to run a production server.

Technically, you can do what you described.  What results it will have in the practice, 
you will find out.

Just to stress some points made earlier then :
- "Initial Memory pool" corresponds to the Java command-line parameter "-Xms"
and indicates the initial (and I believe minimum size) of the Java Heap.
- "Maximum Memory pool" corresponds to the Java command-line parameter "-Xmx"
and indicates the maximum size of the Java Heap.

(you will find a more complete list of options here : 
http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/java.html)

The heap is part of how much memory each of your Tomcat instances will need, but it is not 
  not all the memory that they will need.

If you are short of physical memory, you may want to have a look at running multiple 
virtual <Host>'s inside of one Tomcat, rather than one Tomcat instance per 
application/customer.  Multiple <Host> inside Tomcat all share the same Tomcat code and 
the same JVM, so that may be a better way to go than being skimpy on memory per Tomcat.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Free Memory vs. Total Memory vs. Max Memory

Posted by "Robinson, Eric" <er...@psmnv.com>.
> > If your application 
> needs 64MB of 
> > Heap space and you allocate only -Xms16M, then right at the 
> start the 
> > JVM will have to increase the Heap to 64MB (minimum); so 
> why would you 
> > do that ?
> 

64MB was just a number I threw out. The app actually uses about 20MB at
startup, so we might consider setting the minimum pool to 25M.

> I can see the lure of "only taking what you need" and 
> allowing the JVM to automatically re-size the memory space: 
> that way, you only take up a huge chunk of memory during peak 
> load and not all the time.
> 
> But why?
> 
> If you are going to need, say, 512MiB at peak load, you're 
> going to need that memory available whether or not it is 
> allocated to the JVM itself at any given time. If that's the 
> case, why not let the JVM have that memory all the time?


Because the server has about 100 instances of tomcat. They do not all
need the memory at the same time.

--Eric





Disclaimer - February 17, 2012 
This email and any files transmitted with it are confidential and intended solely for Tomcat Users List. If you are not the named addressee you should not disseminate, distribute, copy or alter this email. Any views or opinions presented in this email are solely those of the author and might not represent those of Physicians' Managed Care or Physician Select Management. Warning: Although Physicians' Managed Care or Physician Select Management has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments. 
This disclaimer was added by Policy Patrol: http://www.policypatrol.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Free Memory vs. Total Memory vs. Max Memory

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Eric,

On 2/17/12 3:28 AM, André Warnier wrote:
> Robinson, Eric wrote:
>> What are the possible downsides of setting a low initial memory
>> pool and a high max pool? If a tomcat app usually needs
>> approximately 64MB of heap space, but sometimes as much as
>> 300-400MB, would it cause any problems to set the initial pool to
>> 16M and the max pool to 512M?
>> 
> It depends... ;-)
> 
> If you set different values to -Xms (at start) and -Xmx (maximum),
> then the JVM will spend some amount of time allocating and
> de-allocating Heap memory dynamically as needed, to stay within
> these boundaries. If they are equal, then the JVM allocates it at
> start, and never has to worry about it later. If your application
> needs 64MB of Heap space and you allocate only -Xms16M, then right
> at the start the JVM will have to increase the Heap to 64MB
> (minimum); so why would you do that ?

I'll add a bit to André's comments:

I can see the lure of "only taking what you need" and allowing the JVM
to automatically re-size the memory space: that way, you only take up
a huge chunk of memory during peak load and not all the time.

But why?

If you are going to need, say, 512MiB at peak load, you're going to
need that memory available whether or not it is allocated to the JVM
itself at any given time. If that's the case, why not let the JVM have
that memory all the time? Freeing the memory manager from having to
re-size the heap (and that means re-sizing the various pools within
the entire heap as well) will definitely improve your performance.

Remember that "giving back" memory to the OS isn't as simple as just
drawing a line at the top of the heap and chopping-off the empty top:
each pool must be re-sized to its new size, moving objects around all
over the place so that the top of the heap is empty and *then*
releasing the memory.

It used to be that the JVM would never release memory it had claimed,
so if you have -Xmx512M and you hit that limit at peak load, then your
heap would never go smaller than that. I don't know if it's the case
any longer because I always set Xms=Xmx so that I don't have the
memory manager wasting all that time.

Hope that helps,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8+bFIACgkQ9CaO5/Lv0PBcegCgmE1OHDV2djU0MXY3vRggaNnZ
YhMAn2prZeN9RjC5MTUfDC+KKS2aGCSz
=EGpQ
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Free Memory vs. Total Memory vs. Max Memory

Posted by André Warnier <aw...@ice-sa.com>.
Robinson, Eric wrote:
>> Note that you are talking of "memory pool", which is a bit 
>> vague.  The -Xms and -Xmx parameters relate to how big the 
>> Heap is, which is only one part of the memory space needed by the JVM.
>>
> 
> I am just using the terms that I see on the screen when I pull up
> tomcat6w.exe.
> 
You're right.
Mmm, that looks a bit unfortunate as a label in that tomcat6w dialog.
In the Windows Registry at
HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\Tomcat6\Parameters\Java
at least they are named "JvmMs" and "JvmMx".

On the other hand, this is the first time that you mention that you are running this on 
Windows, so I don't feel too bad.
;-)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Free Memory vs. Total Memory vs. Max Memory

Posted by "Robinson, Eric" <er...@psmnv.com>.
> Note that you are talking of "memory pool", which is a bit 
> vague.  The -Xms and -Xmx parameters relate to how big the 
> Heap is, which is only one part of the memory space needed by the JVM.
> 

I am just using the terms that I see on the screen when I pull up
tomcat6w.exe.

--Eric




Disclaimer - February 17, 2012 
This email and any files transmitted with it are confidential and intended solely for Tomcat Users List. If you are not the named addressee you should not disseminate, distribute, copy or alter this email. Any views or opinions presented in this email are solely those of the author and might not represent those of Physicians' Managed Care or Physician Select Management. Warning: Although Physicians' Managed Care or Physician Select Management has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments. 
This disclaimer was added by Policy Patrol: http://www.policypatrol.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Free Memory vs. Total Memory vs. Max Memory

Posted by André Warnier <aw...@ice-sa.com>.
Robinson, Eric wrote:
> What are the possible downsides of setting a low initial memory pool and
> a high max pool? If a tomcat app usually needs approximately 64MB of
> heap space, but sometimes as much as 300-400MB, would it cause any
> problems to set the initial pool to 16M and the max pool to 512M?
>  
It depends... ;-)

If you set different values to -Xms (at start) and -Xmx (maximum), then the JVM will spend 
some amount of time allocating and de-allocating Heap memory dynamically as needed, to 
stay within these boundaries. If they are equal, then the JVM allocates it at start, and 
never has to worry about it later.
If your application needs 64MB of Heap space and you allocate only -Xms16M, then right at 
the start the JVM will have to increase the Heap to 64MB (minimum); so why would you do that ?

If you are talking about a workstation, and for testing, then you can do whatever pleases 
you and play around. If you are talking about a server, then the logical thing to do would 
be to estimate how big a Heap you need in a maximum expected load situation, round that up 
somewhat, and set -Xms and -Xmx both to that same value.
There are other command-line parameters to the JVM, which allow to ask the Garbage 
Collector to write a log, which can help in determining what the optimal Heap size would 
be, in your situation.  There is no "one size fits all".

Note that you are talking of "memory pool", which is a bit vague.  The -Xms and -Xmx 
parameters relate to how big the Heap is, which is only one part of the memory space 
needed by the JVM.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Free Memory vs. Total Memory vs. Max Memory

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Robinson, Eric [mailto:eric.robinson@psmnv.com] 
> Subject: RE: Free Memory vs. Total Memory vs. Max Memory

> If what you described occurs, we would see OOMs in the 
> logs, correct?

Only rarely.  More typical is slow response and annoyed end users.

> Also, if the machine has inadequate RAM, then the effect you 
> described could be the same whether you specify a low or high
> -Xms value, correct?

Eventually, yes.  But by setting -Xms to the same as -Xmx, you will get an indication immediately, as swap space gets allocated for the various JVM instances at startup, not later when you're under heavy load.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Free Memory vs. Total Memory vs. Max Memory

Posted by "Robinson, Eric" <er...@psmnv.com>.
> > What are the possible downsides of setting a low initial 
> memory pool 
> > and a high max pool? If a tomcat app usually needs 
> approximately 64MB 
> > of heap space, but sometimes as much as 300-400MB, would it 
> cause any 
> > problems to set the initial pool to 16M and the max pool to 512M?
> 
> An additional answer to your question:
> 
> If multiple JVMs need, in total, more RAM than the machine 
> has available at any given moment, the OS may allocate swap 
> memory to one or more of those processes.  Once a JVM is 
> moved into swap, it is difficult to predict when it will move 
> back out again.
> 
> For JVMs this is particularly bad, as internal memory 
> operations inside the process will take orders of magnitude 
> longer to complete.  This can negatively impact the timing of 
> garbage collection and lead to an increased risk of OOM, for 
> some collectors.
> 
> 

Thanks for the additional information. If what you described occurs, we
would see OOMs in the logs, correct? Also, if the machine has inadequate
RAM, then the effect you described could be the same whether you specify
a low or high -Xms value, correct?

--Eric





Disclaimer - February 20, 2012 
This email and any files transmitted with it are confidential and intended solely for Tomcat Users List. If you are not the named addressee you should not disseminate, distribute, copy or alter this email. Any views or opinions presented in this email are solely those of the author and might not represent those of Physicians' Managed Care or Physician Select Management. Warning: Although Physicians' Managed Care or Physician Select Management has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments. 
This disclaimer was added by Policy Patrol: http://www.policypatrol.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Free Memory vs. Total Memory vs. Max Memory

Posted by Pid <pi...@pidster.com>.
On 17/02/2012 04:58, Robinson, Eric wrote:
> What are the possible downsides of setting a low initial memory pool and
> a high max pool? If a tomcat app usually needs approximately 64MB of
> heap space, but sometimes as much as 300-400MB, would it cause any
> problems to set the initial pool to 16M and the max pool to 512M?

An additional answer to your question:

If multiple JVMs need, in total, more RAM than the machine has available
at any given moment, the OS may allocate swap memory to one or more of
those processes.  Once a JVM is moved into swap, it is difficult to
predict when it will move back out again.

For JVMs this is particularly bad, as internal memory operations inside
the process will take orders of magnitude longer to complete.  This can
negatively impact the timing of garbage collection and lead to an
increased risk of OOM, for some collectors.


p



-- 

[key:62590808]