I'm new to Geoserver, Ubuntu and Java, but have downloaded a virtual machine from gisvm.com and am getting up to speed. I got as far as configuring it with some fairly large shapefiles from a project I've worked on previously.

My question is related to a problem which I see if I show the shapefile using the OpenLayers layer preview option. I see an error:

OpenLayers map preview code="internalError" Rendering process failed. java.lang.OutOfMemoryError: Java heap space

Googling has led me to plenty of Java command line options to increase heap space, but I have no idea if this should be applied to an environment variable, in a startup script or as a part of the Geoserver config.

Can you help me to understand what I need to edit to get this working?

I'm also wondering if I should be splitting my shapefile into smaller pieces.

| improve this question | | | | |

You must change memory heap in your JVM. I supposed that gisvm.com use Tomcat, so you can find a lot of tutorials about "increase java heap space in Tomcat" in google. Basically is add -Xmx128m parameter to JVM to increasing memory heap.

| improve this answer | | | | |
  • 1
    Ah, ok, I found that /etc/default/tomcat6 contains this line: JAVA_OPTS="-Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC" - I guess I edit that? Trying -Xmx512m ... – Elliveny May 31 '11 at 15:22
  • I tried it and it worked! Thanks for the pointer to Tomcat, I hadn't realised that it was involved. – Elliveny Jun 1 '11 at 9:57

I've had the same error message on a Windows Server with GeoServer using Jetty. After some research I found the file C:\Program Files (x86)\GeoServer 2.10.1\wrapper\wrapper.conf where I edited these two lines:

# Initial Java Heap Size (in MB)

# Maximum Java Heap Size (in MB)

Seems to have done the trick...

I found a hint to this file here: http://osgeo-org.1560.x6.nabble.com/Geoserver-heap-size-permgen-space-configuration-td5145590.html

| improve this answer | | | | |

You can increase Memory Allocation in the following ways

(performance settings in the Java virtual machine (JVM) for your container)

-Xmx256M -Xms48m

"Allocates extra memory to your server. By default, JVM will use only 64MB of heap. If you’re serving just vector data, you’ll be streaming, so having more memory won’t increase performance. If you’re serving coverages, however, JAI will use a disk cache. -Xmx256M allocates 256MB of memory to GeoServer (use more if you have excess memory). It is also a good idea to configure the JAI tile cache size (see the Server Config page in the Web Administration Interface section) so that it uses 75% of the heap (0.75). -Xmx48m will tell the virtual machine to grab a 48MB heap on startup, which will make heap management more stable during heavy load serving."


"Increases the maximum size of permanent generation (or “permgen”) allocated to GeoServer to 128MB. Permgen is the heap portion where the class bytecode is stored. GeoServer uses lots of classes, and it may exhaust that space quickly, leading to out of memory errors. This is especially important if you’re deploying GeoServer along with other applications in the same container, or if you need to deploy multiple GeoServer instances inside the same container."


| improve this answer | | | | |
  • Thanks; I found this previously but it didn't help me much. From my unfamiliar-with-this-stuff point of view, it doesn't tell me what to edit in my Ubuntu VM - where do I put those switches? Where do I find the 'performance settings in the Java virtual machine (JVM) for your container'? – Elliveny May 31 '11 at 15:20
  • Well, to my understanding the options you mentioned are valid for Oracle's JVM, that is, not standard, and even not stable. "Options that begin with -X are non-standard (not guaranteed to be supported on all VM implementations), and are subject to change without notice in subsequent releases of the JDK. Options that are specified with -XX are not stable and are not recommended for casual use. These options are subject to change without notice." (oracle.com/technetwork/java/javase/tech/…). The question has problem: Elliveny is not telling us what JVM is using. – dariapra Jun 2 '11 at 17:43
  • Java is owned by oracle - en.wikipedia.org/wiki/Java_%28programming_language%29 So GeoServer should be bundling extensions with the package. I found all the extensions for oracle connections disjointed but did get it to work. – Mapperz Jun 2 '11 at 19:20
  • 1
    @Mapperz Java is not owned by Oracle. There are a lot of implementations of JVM. but the more famous implementation is Oracle JVM. List (not complete) of JVM implementations: en.wikipedia.org/wiki/List_of_Java_virtual_machines – angelcervera Nov 12 '12 at 9:15

Changing Java Heap Memory for Geoserver

sudo vi /usr/share/tomcat7/bin/catalina.sh

line 3

export CATALINA_OPTS="-Xms2048m -Xmx8g"

Change the "-Xmx2048m" to desired value, as Xmx is case sensitive, you can use "g" for GB or "m" for MB

After the changes are saved, remember to restart tomcat:

sudo services tomcat7 restart

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.