Question & Answer
Question
How to avoid "java.lang.OutOfMemoryError: Java heap space" exceptions when uploading large documents using the IBM Navigator CMIS interface ?
Answer
When uploading larger documents ( typically > 10 MB in size) using the CMIS createDocument function which sets properties, content and the version state in a single call may fail with a Error 500: java.lang.OutOfMemoryError: Java heap space".? The exact document size when this issue may be encounter this issue depends on system configuration and state.
Use of the CMIS createDocument function results in a heap memory allocation between 3x-5x the size of the document being uploaded in the JVM where the CMIS interface of IBM Navigator is hosted.? For large documents the allocation requests may be considerable.? The heap may also be consumed rapidly if a large number of requests of smaller documents are submitted at the same time.?
When uploading documents? that exceed 1-2 MB through the IBM Navigator CMIS interface instead of using the CMIS createDocument function :
Document newDoc = parent.createDocument(properties contentStream VersioningState.MAJOR);
Create the document without setting the content :
Document newDoc = parent.createDocument(props null VersioningState.CHECKEDOUT)
Build a content stream and set it on the document then check in the document :
ContentStream cs = session.getObjectFactory().createContentStream(name file.size()mimetypenew FileInputStream(file));
newDoc.setContentStream(contentStream true true);
newDoc.checkIn(true null null "")
This sequence results in the content being streamed to the CMIS interface and using considerably less heap allocation and allows for the upload a larger documents that may otherwise fail when using the single createDocument call.
Was this topic helpful?
Document Information
Modified date:
30 August 2022
UID
ibm10774859