Welcome to yEd Q&A!
Here you can ask questions and receive answers from other members of the community and yEd developers. And you can tell us your most wanted feature requests.

Categories

How can I prevent 'Out of Memory' errors in yEd?

+3 votes
in Help by (3.4k points)

1 Answer

+4 votes
 
Best answer

The following advice applies to yEd version 3.16 and before.
As of yEd version 3.16.1, the maximum heap space of the Java virtual machines that come bundled with yEd installers is not restricted anymore.


You can prevent 'Out of Memory' errors by extending the Java heap space for yEd.

yEd is a Java application and, as such, constrained by the Java Virtual Machine (JVM) it runs in. The JVM imposes a limit to the amount of memory that an application can use.

Even if your computer has more memory, yEd cannot use it, i.e., if yEd needs more memory than its limit, an OutOfMemoryError occurs with a message like "java heap space out of memory".

By default, the maximum amount of memory available to yEd is set to 512 MB (beginning with version 3.7.0.1; prior versions used 256 MB). This limit can be set to a different value at the startup of a Java application.

To increase this limit for yEd, do the following:

  • If you used the yEd Installer for Windows, you can add a parameter to the link on the desktop.
    1. Right click on the yEd icon on the desktop to open the context menu and select the entry 'Properties'.
    2. In the field 'Target', add -J-Xmx768m to set the limit to 768 MB. Of course, you can use other values, too.
      For example, the field's content should be similar to
      "C:\Program Files\yWorks\yEd\yEd.exe" -J-Xmx768m
    3. Click 'OK' to close the dialog. If you subsequently start yEd by double clicking the link on the desktop, it will use up to 768 MB of memory.
  • On Windows, you can also use this attached batch script to start yEd with custom parameters for Java's memory limit. Please have a look at the comments in the batch file which describe how to use it.
  • If you used the yEd Installer for Mac OS X, you can adjust the Info.plist file in the yEd.app directory:
    For the VMOptions key, use as the new value -Xmx768m instead of the original value.
    As of yEd 3.13, additional options have to be placed in section [JVMOptions] of file yEd.app/Contents/Java/yEd.cfg.
    As of yEd 3.19.1.1, additional options have to be placed in section [JavaOptions] of file yEd.app/Contents/app/yEd.cfg.
    As of yEd 3.21, entries in section [JavaOptions] of file yEd.app/Contents/app/yEd.cfg have to be prefixed with java-options=, e.g.
    java-options=-Xmx768m
  • On Linux, open the yEd shell script, which is located in the yEd installation directory, in a text editor. Go to the second to last line and find "-Xmx512m". Change 512 to a higher value.
  • On any operating system with an installed Java Runtime Environment (JRE) you can also directly run yEd from the command line and set the heap space limit as follows.
    1. Open a command prompt.
    2. Go to the directory where yEd is installed.
    3. Type java -Xmx768m -jar yed.jar and hit the return key.

Warning

Specifying too much heap space may prevent yEd from starting. In this case an error message "The JVM could not be started. The main method may have thrown an exception." may be shown.

by [yWorks] (23.7k points)
edited by
For macOS, the VMOptions key is no longer in Info.plist. However, adding the following to Contents/Java/yEd.cfg appears to work:

[JVMOptions]
-Xdock:name=yEd
-Xmx2g
I dont get it, im using Mac in 2024 & I dont understand it
If you run into an "OutOfMemoryError" with a recent Java version (e.g. Java 21), then the problem cannot be solved with the approach explained here. Your machine needs more RAM.

You can check the Java version your yEd is running on in "Help" -> "About". You can also check how much memory is available to yEd in "Help" -> "About".
it says 2GB is the maximum but I have more RAM
227MB/2GB?
can I do something or my Mac is at its limit? I think I have more like 8GB or 16GB is there a solution?

Well, there might be a way to use more of your machine's RAM, but it is quite involved: you can try to install a current Java runtime environment (JRE) on your machine and run yEd from command line with that separate JRE.

Once you have installed a JRE (typically in /Library/Java/JavaVirtualMachines) find a subdirectory bin in the JRE installation directory that contains an executable named java and run yEd like so:

<path_to_jre_bin>/java -Xmx4096m \
 --add-opens java.base/java.io=ALL-UNNAMED\
 --add-opens java.desktop/javax.swing=ALL-UNNAMED\
 --add-opens java.desktop/sun.swing=ALL-UNNAMED\
 --add-opens java.desktop/com.apple.laf=ALL-UNNAMED\
 --add-opens java.desktop/com.apple.eawt=ALL-UNNAMED\
 --add-opens java.desktop/com.apple.eawt.event=ALL-UNNAMED\
 --add-opens java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED\
 -jar /Applications/yEd.app/Contents/Resources/app/yed.jar

The value 4096m for the -Xmx option used above would increase the memory available to yEd from 2GB to 4GB. You will need to specify a value greater than the default 2GB but about 1GB less than the available physical memory in your machine. If the value is too large, Java will slow down to a crawl.

Good luck.

Legal Disclosure | Privacy Policy
...