Performance Issue at Linux RedHat | java.lang.NullPointerException

When the file size exceeds 50M , NPE happend.
Linux RedHat, JVM heapSpace 4G ,Total Memory 16 G.
I’m using aspose.words-20.4-jdk17.jar

Here is stacktrace,and I noticed this “at com.aspose.words.zzZEQ.flush(Unknown Source)”
java.lang.NullPointerException
at com.aspose.words.zzZEQ.flush(Unknown Source)
at com.aspose.words.zzYTB.zz9(Unknown Source)
at com.aspose.words.zzZX4.zzY(Unknown Source)
at com.aspose.words.zzZX4.zzX(Unknown Source)
at com.aspose.words.zzZX4.zzT(Unknown Source)
at com.aspose.words.zzZ4Q.zzN(Unknown Source)
at com.aspose.words.zzZ42.zzG(Unknown Source)
at com.aspose.words.zzYTB.zz9(Unknown Source)
at com.aspose.words.zz8I.zzG(Unknown Source)
at com.aspose.words.zz8J.zzZ(Unknown Source)
at com.aspose.words.zz8J.zzZEj(Unknown Source)
at com.aspose.words.zzZ4X.zzZEj(Unknown Source)
at com.aspose.words.zz03.zzZrN(Unknown Source)
at com.aspose.words.zz03.zzZrQ(Unknown Source)
at com.aspose.words.zz03.zzZ(Unknown Source)
at com.aspose.words.zz03.zzYW(Unknown Source)
at com.aspose.words.Document.zzZFw(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
at com.test.util.FileConvertUtil.wordToPdf(FileConvertUtil.java:72)
at com.test.controller.TranToImageServlet.doGet(TranToImageServlet.java:69)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

@perhamer

Please note that performance and memory usage all depend on complexity and size of the documents you are generating.

If you are loading huge Word documents into Aspose.Words’ DOM, more memory would be required. This is because during processing, the document needs to be held wholly in memory. Usually, Aspose.Words needs 10 times more memory than the original document size to build a DOM in the memory.

We suggest you please use SaveOptions.MemoryOptimization property to optimize the memory performance. Setting this option to true can significantly decrease memory consumption while saving large documents at the cost of slower saving time.

You are using old version of Aspose.Words for Java. We suggest you please use the latest version of Aspose.Words for Java 20.11. Hope this helps you.