Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

java - Tomcat: adjust memory proportions

I have a Tomcat instance running on a Windows 2008 Server with 4GB of RAM. The server is dedicated to this one application, so I would quite like to be able to dedicate most of the RAM to Tomcat. My Tomcat setup currently has the following java options:

-Xms256m

-Xmx1600m

I'd like to increase the amount of RAM, preferably up to about 3GB (obviously I know how to do that, just increase the -Xmx value). However, Tomcat refuses to start up if I increase the maximum heap space beyond 1600MB. Several websites that I have read say that Tomcat cannot use more than 40% of the available RAM, which seems consistent with what I'm seeing.

Is there a way of increasing the proportion of memory that Tomcat can use, so that I can increase the amount of memory that Tomcat can use?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your issue was probably OS related, not Tomcat / Java. The Windows OS limits the memory allocation of a 32-bit process to 2 GiB in total (by default).

The reason why it only allowed you to allocate around 1.5 GiB heap space is because there is also other memory allocated to the process (the JVM / library overhead, perm gen space etc.).

Why does 32-bit Windows impose a 2 GB process address space limit, but 64-bit Windows impose a 4GB limit?

Other modern operating systems [cough Linux] allow 32-bit processes to use all (or most) of the 4 GiB addressable space.

That said, 64-bit Windows OS's can be configured to increase the limit of 32-bit processes to 4 GiB (3 GiB on 32-bit):

http://msdn.microsoft.com/en-us/library/windows/desktop/aa366778(v=vs.85).aspx

However, as you've rightly done, the best solution is to use a 64-bit JVM with your 64-bit OS. Terabyte heaps anyone:

Max memory for 64bit Java :D


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...