We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Getting Java heap space in "new Document("Document.doc");" constructor while using it to open a .docx file of more than 1.5 MB size

Hi,

I am getting following error while calling the “new Document(…)” as below mentioned code in highlighted for open a file of more tha 1.5 MB as attached “Data 1MB.docx”.

java.lang.OutOfMemoryError: Java heap space
at asposewobfuscated.zzEU.zzUA(Unknown Source)
at asposewobfuscated.zzEU.zzUB(Unknown Source)
com.aspose.words.Document wordDoc = new com.aspose.words.Document(webdavDir+"/"+fileNameSub);
DocSaveOptions saveOptions = new DocSaveOptions();
saveOptions.setSaveFormat(SaveFormat.DOCX);
saveOptions.setTempFolder(webdavDir);
wordDoc.save(out, saveOptions);

I have increased heap size up to xmx1024m too.

Kindly help us.

Thanks & Regards,
Awanish

Hi Awanish,

Thanks for your inquiry. I have tested the scenario and have not found the shared issue while using latest version of Aspose.Words for Java 14.12.0. Please use Aspose.Words for Java 14.12.0 and let us know if you have any more queries.

Hi Tahir,

I used the latest Aspose.Words for Java 14.12.0. jars but still getting Java Heap Space error. PFB stack trace.

Jan 21, 2015 1:59:45 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet GetThumbnailServlet threw exception
java.lang.OutOfMemoryError: Java heap space
at asposewobfuscated.zzBG.zzUg(Unknown Source)
at asposewobfuscated.zzBG.zzUh(Unknown Source)
at asposewobfuscated.zzBG.write(Unknown Source)
at asposewobfuscated.zz9U.zzZ(Unknown Source)
at asposewobfuscated.zzCI.zzh(Unknown Source)
at asposewobfuscated.zzLM.zzh(Unknown Source)
at asposewobfuscated.zzMR.zzr(Unknown Source)
at asposewobfuscated.zzMR.zzs(Unknown Source)
at asposewobfuscated.zzMR.(Unknown Source)
at com.aspose.words.zz8A.(Unknown Source)
at com.aspose.words.Document.zzY(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.citi.pe.per.webdav.GetThumbnailServlet.doGet(GetThumbnailServlet.java:72)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.citi.pe.per.web.PERFilter.doFilter(PERFilter.java:145)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)

I think it is giving error due to use of DOM Parser in API to create document structuter in memory. I beleave it SAX parser will use then this problem will not occure.

My code is still same as below.

com.aspose.words.Document wordDoc = new com.aspose.words.Document(webdavDir+"/"+fileNameSub);
DocSaveOptions saveOptions = new DocSaveOptions();
saveOptions.setSaveFormat(SaveFormat.PNG);
saveOptions.setTempFolder(webdavDir);
wordDoc.save(out, saveOptions);

Kindly help us.

Thanks & Regards,
Awanish

Hi Awanish,

Thanks for your inquiry. I am afraid I have not found the shared issue while using Aspose.Words v14.12.0. Please note that DocSaveOptions.SaveFormat can only be Doc or Dot. Please change the save format in your code. The shared code should throw ‘An invalid SaveFormat for this options type was chosen’ exception.

Please create a separate application and use following code example and let us know if you still face problem.

Document doc = new Document(MyDir + "Data+1MB.docx");
DocSaveOptions saveOptions = new DocSaveOptions();
saveOptions.setSaveFormat(SaveFormat.DOC);
saveOptions.setTempFolder("c:\\temp");
ByteArrayOutputStream dstStream = new ByteArrayOutputStream();
doc.save(dstStream, saveOptions);