Debugging java.lang.OutOfMemoryError issues

Having trouble installing Oxygen PDF Chemistry? Got a bug to report? Post it all here.
chrispitude
Posts: 585
Joined: Thu May 02, 2019 2:32 pm

Debugging java.lang.OutOfMemoryError issues

Post by chrispitude »

I have a DITA-OT project file with about 30 deliverables. When I run the "All Deliverables" transformation, the largest book sometimes crashes as follows:

Code: Select all

     [exec]      [java] INFO  LoggingEventListener - Rendered page #4202.
     [exec]      [java] INFO  LoggingEventListener - Rendered page #4203.
     [exec]      [java] INFO  LoggingEventListener - Rendered page #4204.
     [exec]      [java] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
     [exec]      [java] 	at java.base/java.util.Arrays.copyOf(Arrays.java:3537)
     [exec]      [java] 	at java.base/java.io.ByteArrayOutputStream.toByteArray(ByteArrayOutputStream.java:185)
     [exec]      [java] 	at com.oxygenxml.chemistry.e.eb.b(Unknown Source)
     [exec]      [java] 	at com.oxygenxml.chemistry.OxygenPDFChemistry.b(Unknown Source)
     [exec]      [java] 	at com.oxygenxml.chemistry.OxygenPDFChemistry.processInternal(Unknown Source)
     [exec]      [java] 	at com.oxygenxml.chemistry.OxygenPDFChemistry$1.b(Unknown Source)
     [exec]      [java] 	at com.oxygenxml.chemistry.OxygenPDFChemistry$1.run(Unknown Source)
     [exec]      [java] 	at ro.sync.security.SandboxCore.runWithConfirmation(SandboxCore.java:258)
     [exec]      [java] 	at ro.sync.security.ConnectionsSandbox.runWithConnectConfirmation(ConnectionsSandbox.java:263)
     [exec]      [java] 	at ro.sync.security.Sandbox.runWithConnectConfirmation(Sandbox.java:355)
     [exec]      [java] 	at com.oxygenxml.chemistry.OxygenPDFChemistry.process(Unknown Source)
     [exec]      [java] 	at com.oxygenxml.chemistry.OxygenPDFChemistry.process(Unknown Source)
     [exec]      [java] 	at com.oxygenxml.chemistry.OxygenPDFChemistry.process(Unknown Source)
     [exec]      [java] 	at com.oxygenxml.chemistry.OxygenPDFChemistry.main(Unknown Source)
     [exec] Error: The following error occurred while executing this line:
     [exec] C:\Program Files\Oxygen XML Editor 25 - 2022081006\frameworks\dita\DITA-OT3.x\plugins\com.oxygenxml.pdf.css\build.xml:670: Java returned: 1

BUILD FAILED
C:\Users\chrispy\git\dita-ams\prj\frameworks\dita\dita_project\build_dita_project_preprocessed.xml:25: exec returned: 1

Total time: 52 minutes 21 seconds
My Windows 10 laptop has 16GB physical memory. With -Xmx8192m, this PDF deliverable always crashes. With -Xmx10240m, it only sometimes crashes.

Another writer has a Windows 10 laptop with 16GB physical memory, and the transformation always crashes for her even with -Xmx10240m (although we only ran it a few times, so "always" is based on a small dataset).

Part of the difficulty in debugging this is the lack of information. For example,
  • Does a deliverable require more memory when published in a set of "All Deliverables" versus published by itself?
  • Does a transformation's -X memory limit include what Oxygen itself uses, or do the transformation and Oxygen each have their own limit? (related docs here)
  • How do I differentiate between an insufficient -X limit versus the -X limit not getting reached due to other applications consuming memory on the machine?
  • Does the -X limit consider available Windows 10 virtual memory, or just physical memory?
Interestingly, the PDF transformation always crashes after the last "Rendered page #..." line for the document (that value is always the total page count of the document), so the crash seems to be after the page rendering step.

As an enhancement idea, perhaps Oxygen could somehow print the highest memory usage for both failed transformations and successful transformations. This would provide visibility into whether the -X limit was reached and thus is insufficient, versus not reached due to unavailable system resources.

I can provide a testcase upon request. Thanks!
julien_lacour
Posts: 306
Joined: Wed Oct 16, 2019 3:47 pm

Re: Debugging java.lang.OutOfMemoryError issues

Post by julien_lacour »

Hi Chris,

For analysis, could you provide us the part of the console that calls Chemistry, it starts with:

Code: Select all

     [exec] pdf-css.chemistry:
     [exec] 
     [exec] pdf-css.chemistry.embedded:
     [exec]      [echo] =============================
     [exec]      [echo] Oxygen PDF Chemistry
     [exec]      [echo] Installation directory: ...
Regarding your questions:
  • The transformation using DITA project file should be equivalent to the transformation scenario with the Prefer using the "dita" command option unchecked.
  • The -Xmx parameter set is only used by the transformation and not by Oxygen itself.
  • The OutOfMemory error mean that the -X limit has been reached, the other applications should not interfere here.
  • The -X memory is Java virtual memory, the link between it and Windows memory is a little complicated as the operating system itself manage how the memory is used.
I added an issue to enhance the console log, we will add the original available memory and in case of error the total consumed memory. Thank you for the request!

Regards,
Julien
chrispitude
Posts: 585
Joined: Thu May 02, 2019 2:32 pm

Re: Debugging java.lang.OutOfMemoryError issues

Post by chrispitude »

Thanks Julien! I appreciate the answers, that should help us intelligently perform further investigation. Also, the plan to add additional memory information to both successful and failing transformations will be very helpful in the future.

Here is the requested portion of the log:

Code: Select all

     [exec] pdf-css.chemistry.embedded:
     [exec]      [echo] =============================
     [exec]      [echo] Oxygen PDF Chemistry
     [exec]      [echo] Installation directory: C:\Program Files\Oxygen XML Editor 25 - 2022081006\frameworks\dita\DITA-OT3.x\bin\../../../..
     [exec]      [echo] Processing: C:\Users\chrispy\git\dita-ams\temp\stage1.xml.pp
     [exec]      [echo] Output file: C:\Users\chrispy\git\dita-ams\out\final\olh_cc\pdf/cc_tclref.pdf
     [exec]      [echo] =============================
     [exec]      [java] INFO  OxygenPDFChemistry - oXygen PDF Chemistry version 25.0 build 2022-08-10T02:52:53Z
     [exec]      [java] INFO  OxygenPDFChemistry - Using catalogs: [file:/C:/Program%20Files/Oxygen%20XML%20Editor%2025%20-%202022081006/config/catalogs/catalog.xml, file:/C:/Program%20Files/Oxygen%20XML%20Editor%2025%20-%202022081006/frameworks/dita/DITA-OT3.x/catalog-dita.xml, file:/C:/Program%20Files/Oxygen%20XML%20Editor%2025%20-%202022081006/frameworks/docbook/catalog.xml]
     [exec]      [java] INFO  x - CSS: file:/C:/Program%20Files/Oxygen%20XML%20Editor%2025%20-%202022081006/frameworks/dita/DITA-OT3.x/plugins/com.oxygenxml.webhelp.responsive/oxygen-webhelp/app/topic-page-print.css
     [exec]      [java] INFO  x - CSS: file:/C:/Program%20Files/Oxygen%20XML%20Editor%2025%20-%202022081006/frameworks/dita/DITA-OT3.x/plugins/com.oxygenxml.pdf.css/css/print/p-dita.css
     [exec]      [java] INFO  x - CSS: file:/C:/Program%20Files/Oxygen%20XML%20Editor%2025%20-%202022081006/frameworks/dita/DITA-OT3.x/plugins/com.oxygenxml.editlink/pdf-css.css
     [exec]      [java] INFO  x - CSS: file:/C:/Users/chrispy/git/dita-ams/dita/_common/_template/../../../prj/frameworks/dita/css/synopsys.css
     [exec]      [java] INFO  OxygenPDFChemistry - Dumping styled content to: C:\Users\chrispy\git\dita-ams\out\final\olh_cc\pdf\cc_tclref.style.xml
     [exec]      [java] INFO  OxygenPDFChemistry - Dumping FO content to: C:\Users\chrispy\git\dita-ams\out\final\olh_cc\pdf\cc_tclref.fo
     [exec]      [java] INFO  LoggingEventListener - Rendered page #1.
     [exec]      [java] INFO  LoggingEventListener - Rendered page #2.
...omitted...
     [exec]      [java] INFO  LoggingEventListener - Rendered page #4203.
     [exec]      [java] INFO  LoggingEventListener - Rendered page #4204.
     [exec]      [java] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
     [exec]      [java] 	at java.base/java.util.Arrays.copyOf(Arrays.java:3537)
     [exec]      [java] 	at java.base/java.io.ByteArrayOutputStream.toByteArray(ByteArrayOutputStream.java:185)
     [exec]      [java] 	at com.oxygenxml.chemistry.e.eb.b(Unknown Source)
     [exec]      [java] 	at com.oxygenxml.chemistry.OxygenPDFChemistry.b(Unknown Source)
     [exec]      [java] 	at com.oxygenxml.chemistry.OxygenPDFChemistry.processInternal(Unknown Source)
     [exec]      [java] 	at com.oxygenxml.chemistry.OxygenPDFChemistry$1.b(Unknown Source)
     [exec]      [java] 	at com.oxygenxml.chemistry.OxygenPDFChemistry$1.run(Unknown Source)
     [exec]      [java] 	at ro.sync.security.SandboxCore.runWithConfirmation(SandboxCore.java:258)
     [exec]      [java] 	at ro.sync.security.ConnectionsSandbox.runWithConnectConfirmation(ConnectionsSandbox.java:263)
     [exec]      [java] 	at ro.sync.security.Sandbox.runWithConnectConfirmation(Sandbox.java:355)
     [exec]      [java] 	at com.oxygenxml.chemistry.OxygenPDFChemistry.process(Unknown Source)
     [exec]      [java] 	at com.oxygenxml.chemistry.OxygenPDFChemistry.process(Unknown Source)
     [exec]      [java] 	at com.oxygenxml.chemistry.OxygenPDFChemistry.process(Unknown Source)
     [exec]      [java] 	at com.oxygenxml.chemistry.OxygenPDFChemistry.main(Unknown Source)
     [exec] Error: The following error occurred while executing this line:
     [exec] C:\Program Files\Oxygen XML Editor 25 - 2022081006\frameworks\dita\DITA-OT3.x\plugins\com.oxygenxml.pdf.css\build.xml:670: Java returned: 1

BUILD FAILED
C:\Users\chrispy\git\dita-ams\prj\frameworks\dita\dita_project\build_dita_project_preprocessed.xml:25: exec returned: 1
Post Reply