I get a "Cannot create image:Java Heap space" error when I try to Save my Class Diagram. Why?

When you try to export a large model diagram in actual size to .jpg or .png format, the export may fail with the error message "Cannot create image:Java Heap space". For example, the failure may happen with large Class Diagrams that have many elements or elements spread wide apart.

This failure to generate the image happens when the size of the original image to be encoded causes a request for an amount of memory that exceeds the memory available inside the VM instance. The UML module in Netbeans uses a third party graph library which renders the whole image into memory before encoding it. As the behavior of the library cannot be changed to fix the issue, a message is displayed to the user instead.

See Issue 91942 for more details.

There is an issue filed for making the error message more descriptive to the user, see Issue 96194.

How do I save my model diagram when I get this message?

You can try the following :-

1) You can try to start the JVM with larger heap memory size (-Xmx). That helps in case of images up to around 100Mpixel (10Kx10K). Such a 100Mpixel image would require 400Mb piece of RAM alone on top of everything else.

2) Decrease image resolution/size. For example decrease zoom level and use "Current Zoom Level" option on the export dialog.

3) Set the image size explicitly using image size fields on the export dialog.

4) Export the diagram to .svg format.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo