aspose file tools*
The moose likes Tomcat and the fly likes How much is too much memory (heap) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How much is too much memory (heap)" Watch "How much is too much memory (heap)" New topic
Author

How much is too much memory (heap)

David Sheltby
Ranch Hand

Joined: Oct 19, 2011
Posts: 34
I have Tomcat 6 installed on a dedicated server with 16GB of memory. Tomcat is running an application that could potentially have a couple thousand concurrent users. I was considering allocating up to half of the servers memory to the heap. Is there such a thing as too big of a max heap size. 8GB seems like a lot, but I have no metrics to gauge this. Are there any dangers or performance hits that could result in having too much memory allocated?

thanks
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

If you've got it.. use it! ;)

You did not say which OS you are using though, and that could have impact since other processes will fight for the RAM tooth and claw.

You should definitely profile and run some test cases with different amount of users, 10, 100, 500 etc.
JMeter is good for this, then extrapolate the memory usage. This will give you an idea for capacity planning.


WP
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18986
    
    8

William P O'Sullivan wrote:that could have impact since other processes will fight for the RAM tooth and claw.


Indeed that could be a problem. But if you're running a server of this magnitude it would be prudent to avoid running other processes on it which will compete for resources.
David Sheltby
Ranch Hand

Joined: Oct 19, 2011
Posts: 34
Its a Window Server 2008 environment, so somehow I think a few resource fights will be inevitable. There will not be many other third party services installed on this server though. 8GB to the OS and its buddies seems like a decent amount.
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1836
    
    7

I don't think you'll be wanting to utilize 8 GBs of heap space in your application. Unless you don't mind waiting on the garbage collector.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
David Sheltby
Ranch Hand

Joined: Oct 19, 2011
Posts: 34
Jelle Klap wrote:I don't think you'll be wanting to utilize 8 GBs of heap space in your application. Unless you don't mind waiting on the garbage collector.

Max recommendation?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

I don't know that a bigger heap necessarily means a slower garbage collector. YMMV, but last I saw, GCs were being more targeted towards incremental cleanup than the old "freeze-while-I-free-memory" approach.

Too much memory is, quite simply, more memory than you need. If you allocate excess memory and it doesn't get used, you're stealing it from the rest of the system and leaving it idle, which not only reduces what other processes can do, it's a flat waste of the electricity needed to run the memory chips. And/or paging space, depending on your VM configuration.

If you allocate memory and it gets used, but the system will run nearly as efficiently without the extra memory, then you should consider tuning memory settings so that you get the most efficient performance benefits for your JVM while minimizing the impact on the rest of the system.


Customer surveys are for companies who didn't pay proper attention to begin with.
David Sheltby
Ranch Hand

Joined: Oct 19, 2011
Posts: 34
Tim Holloway wrote:I don't know that a bigger heap necessarily means a slower garbage collector. YMMV, but last I saw, GCs were being more targeted towards incremental cleanup than the old "freeze-while-I-free-memory" approach.

Too much memory is, quite simply, more memory than you need. If you allocate excess memory and it doesn't get used, you're stealing it from the rest of the system and leaving it idle, which not only reduces what other processes can do, it's a flat waste of the electricity needed to run the memory chips. And/or paging space, depending on your VM configuration.

If you allocate memory and it gets used, but the system will run nearly as efficiently without the extra memory, then you should consider tuning memory settings so that you get the most efficient performance benefits for your JVM while minimizing the impact on the rest of the system.

Yes, I think some resource monitoring is in order.

thanks
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

Tim is right, the newer GC processing is quite performant at freeing incrementally unlike the earlier ones, which would freeze everything.

However, depending on the OS (Not sure about Win2008), even though the JVM says "I'm done with this clock", the OS may still lock it for a time.

Do some metric testing, generate reports and you'll do fine. I read some where on Windoze that the rule of thumb was to allocate 1/2 the physical memory,
but that may not be valid now.

WP
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

William P O'Sullivan wrote:

Do some metric testing, generate reports and you'll do fine. I read some where on Windoze that the rule of thumb was to allocate 1/2 the physical memory,
but that may not be valid now.

WP


I think that applies to how much swap space, not how much JVM memory. Somewhere between 50-100% of the physical memory is generally advised for swap memory on modern desktop systems. Back when I worked with batch processes on mainframes, when RAM was much more expensive and interactivity was limited to things like CICS and entire address spaces would swap in and out, the guideline used to be more like 8-to-1 on VM-versus-Real Memory. But you don't see much of that anymore.
 
 
subject: How much is too much memory (heap)