Skip to Content

java.lang.OutOfMemoryError: Java heap space When Packacking Large Files

Estimated Reading Time: 3 Minutes

When packaging files to ACS, you may get E_ADEPT_UNKNOWN error.  If you look at the packaging log file, you may see the following memory error:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

This can happen either because that you have a relatively low memory value allocated to Tomcat, or the file is very large and so it needs to be packaged differently using DataPath method.

Files over 100 MB are considered large files. If smaller files are causing this error, it may just be that Tomcat isn't allocated enough memory. We suggest a starting memory pool of 256 MB with a max of at least 1024 MB. This number can certainly be higher, but if your server can't handle it Tomcat will fail during startup. This is especially true for older versions of Tomcat.

To change the memory allocation, on Windows, use the graphical interface to configure Tomcat. The location of this configuration program may vary, but it's usually somewhere like Start/Programs/Tomcat/Configure Tomcat. The memory settings are under the Java tab.

On Linux, you must update Tomcat's startup script. The location of this script varies depending on your Operating System and how you installed Tomcat. Typical places are:

/etc/default/tomcat
/etc/init.d/tomcat
/tomcat/bin

You'll need to add this line, or edit it if the line already exists:

CATALINA_OPTS="$CATALINA_OPTS -server -Xms256m -Xmx1024m "

Be sure to restart Tomcat after making the memory change.

For larger files, typically over 100 MB, you may need to use the DataPath method of packaging. When using the Upload Test tool:

  1. Pass a directory instead of a file on the command line; this directory should contain the file(s) to be packaged and the XML file(s).
  2. Use the command line parameter "-dataPath".
  3. Add a <dataPath> element to each XML file located in the directory path you gave the tool (add this at the top, after the <package...> element). This element should have the full path to the book to be packaged.

The tool will look at every XML in this directory.

Make sure that this file is local on the same system as the packaging server itself.  

If you are packaging the book using your own tool, replace the <data> element of the packaging request with the <dataPath> element, as defined above.

A simple XML file (for the Upload Test tool) or packaging request should look like this:

<package xmlns="http://ns.adobe.com/adept">
    <metadata xmlns:dc="http://purl.org/dc/elements/1.1/">    
       <dc:format>application/pdf</dc:format>
       <dc:title>Datapath Test</dc:title>
    </metadata>
    <dataPath>C:\full\path\to\book\file.pdf</dataPath>
    <permissions>
    </permissions>
</package>

And the command line would look like this:

java -Xmx1024M -jar UploadTest-1_2.jar http://acs-server:8080/packaging/Package path\to\XML\files -datapath -pass XXXXXX

Look at "Packaging Tool Example" in the ACS User Manual, section 11.2. This manual is included with your ACS software installation package.

java.lang.OutOfMemoryError: Java heap space When Packacking Large Files
  • COMMENT

  • Get notified when new articles are added to our knowledge base.