GeoServer – Avoiding Java Out of Heap Space Error

geoserverjavaperformance

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.

Best Answer

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)
wrapper.java.initmemory=16

# Maximum Java Heap Size (in MB)
wrapper.java.maxmemory=128

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