aspose file tools*
The moose likes Linux / UNIX and the fly likes Java low heap size problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Java low heap size problem" Watch "Java low heap size problem" New topic
Author

Java low heap size problem

Jen Hall
Greenhorn

Joined: Sep 18, 2012
Posts: 5
Hi all,

We have a dedicated redhat server for web applications at work:
Linux version 2.6.18-194.11.3.el5.cve20103081 (root@lxslc5-amd64.cern.ch) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Thu Sep 16 15:17:10 CEST 2010

Here's what the memory usually looks like (we usually have about 2.7GB in cache, 4GB total)
free -m
total used free shared buffers cached
Mem: 3951 3855 95 0 248 2523
-/+ buffers/cache: 1083 2868
Swap: 2047 26 2020

Our hosting company installed openjdk 1.6 and tomcat 5.5 for me. When I went in to check the java version, this is what happened:

java -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

So I put on some low min and max heap sizes and tried again and this time it worked:

java -Xms64m -Xmx64m -version
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02, mixed mode)

So I tried continually going up in the sizes until I reached this maximum.

java -Xms256m -Xmx512m -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

And then these are the max settings I can set for Tomcat and Java options in the setenv.sh file of Tomcat. If I go higher, it does a dump and produces an hs_pid file.
export CATALINA_OPTS="-Xms128m -Xmx128m -d64 -XX:PermSize=64m -XX:MaxPermSize=6$
export JAVA_OPTS="-Xms128m -Xmx128m -d64 -XX:PermSize=64m -XX:MaxPermSize=64m"

So, my questions are: why do I only have a maximum of 512M for -version and 128M for Tomcat when there is 2.7GB supposedly available in the cache for applications such as java? Is there some other setting that I need to set? How can I get at some more of that memory?

Thank you much,
Jen
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You mentioned a "hosting company"... is this heap-size restriction possibly something that they built in?
Jen Hall
Greenhorn

Joined: Sep 18, 2012
Posts: 5
I asked them about not being able to actually use the java they installed, and they just said that it was in my hands to change the Java configuration settings.

However, I will ask them specifically if there is any max memory setting for java, but I do doubt it since it's our server -- though they do do some of the installs and keep the WHM/Cpanel and software current, etc.


Jen Hall
Greenhorn

Joined: Sep 18, 2012
Posts: 5
They replied that there should be no limits on the java processes on that machine. They are going to look a little bit into it as well.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

If you think this might be something to do with Linux rather than Java, well, we have a Linux forum and we could move this post over there if you'd like that.
Jen Hall
Greenhorn

Joined: Sep 18, 2012
Posts: 5
What the support from our hosting compnay suggested is that Java is looking for contiguous blocks of memory and may not be able to find it on the machine. I don't know enough about Linux memory to be of any use on how to configure Java to use what Linux might offer at this point.

So, yes I'd appreciate it if you could move this to the Linux forum since this isn't a Java-specific problem. Thank you!
Jen Hall
Greenhorn

Joined: Sep 18, 2012
Posts: 5
This is interesting. So, we rebooted the machine and voila! I can get 1024M min and 2048M max on Tomcat and Java.

The machine had been up for 728 days, a bit too long eh?

So perhaps it was as simple as that.

Thanks,
Jen
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16011
    
  19

"Contiguous blocks of memory" is a bit of a stretch on a virtual memory system, where the physical locations of pages are essentially random. The only case where that would apply would be in IBM-style systems where multiple processes shared a single virtual address space (and I don't think Linux does that).

More likely, starting up the JVM wasn't just eating up chunks of your (extremely small!) "free" memory, it was also grabbing chunks of cache RAM to hold directories, libraries and cached class images, so that the actual "free" state at the time the whole thing simply gave up might not really resemble the idle conditions.

Rebooting kills off a lot of processes (some of which might have been unused or even zombies), thus clearing the slate. But it's possible that you may have problems again as the extra lint starts creeping back in over time.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java low heap size problem