WebFaction
Community site: login faq

Hi,

I'm trying to configure the heap memory used from openjdk (/usr/lib/jvm/jre-1.6.0-openjdk.x86_64) with export JAVA_OPTS="-Xms128m -Xmx128m"

But the process exceeds the 128MB.

Can I limit the memory usage of openjdk?

This question is marked "community wiki".

asked 13 Feb '12, 17:39

alfreale
113
accept rate: 0%


Yes, you can limit the heap size using the -Xmx128m option as you have noted. The -Xms option is for the stack, so you probably don't need to use it, and also the amount of memory you are providing is the sum of these two arguments.

In addition, there is some constant amount of environment and java memory usage in addition to the heap you have provided for the program run within java. Therefore, if you use -Xmx128m, the total memory usage should not exceed (128MB + some_constant).

permanent link

answered 13 Feb '12, 18:53

ryans ♦♦
5.0k93360
accept rate: 43%

My total memory usage exceed the 128MB:

RSS ELAPSED PID COMMAND 277624 01:14 32152 /home/keol/java/bin/java -Djava.util.logging.config.file=/home/keol/webapps/tomcat/conf/logging.properties -Xms64m -Xmx128m -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms64m -Xmx128m -Djava.endorsed.dirs=/home/keol/webapps/tomcat/endorsed -classpath /home/keol/webapps/tomcat/bin/bootstrap.jar:/home/keol/webapps/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/home/keol/webapps/tomcat -Dcatalina.home=/home/keol/webapps/tomcat -Djava.io.tmpdir=/home/keol/webapps/tomcat/temp org.apache.catalina.startup.Bootstrap start

(13 Feb '12, 19:18) alfreale

Well, tomcat itself requires quite a bit of RAM just to run. So that's part of the "some_constant" which I referenced above. But if you run a servlet with some code to fill the stack, that is what should be affected by the stack limits you have specified.

If you need to run a web application in less than 128MB of RAM, java is probably not the best language to use. The base environment for your servlets is already memory-intensive, and the way java handles its objects increases stack usage.

(13 Feb '12, 19:58) ryans ♦♦

I can upgrade to 512m and use for tomcat 384m.

But I think that JVM additionally consumes memory on stack for each thread.

Even I can set the limit of 384m for tomcat application I think that JVM can exceed the limit of 512m.

permanent link

answered 14 Feb '12, 04:15

alfreale
113
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×22

question asked: 13 Feb '12, 17:39

question was seen: 6,356 times

last updated: 14 Feb '12, 04:15

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM