Difference between revisions of "Setting Heap Size"

From Protege Wiki
Jump to: navigation, search
(Start Protege by Protege.exe/Protege or by double-cliking on the Protege icon (Windows/Linux))
 
(12 intermediate revisions by 5 users not shown)
Line 4: Line 4:
 
<span style="font-weight:bold;font-size:16px;">Recommendations for setting the heap size (read first!)</span>
 
<span style="font-weight:bold;font-size:16px;">Recommendations for setting the heap size (read first!)</span>
  
The maximum amount of memory that a Java VM can use is 1.6 GB on Windows XP and 2 GB on most Unix machines.
 
  
 
You must be careful about setting the heap size parameter. If you set it too low then you will get "out of memory" errors. If you set it too high then your system will hang or you will suffer poor performance because parts of the jvm will be swapped in and out of memory. A rule of thumb is that you should not set this parameter larger than about 80% of your free physical memory. On Windows XP machines you can determine your free physical memory from the Performance tab of the Task Manager application. On Mac machines, click the apple (upper left hand corner and "about this mac"). On Linux machines, you can use the wonderful proc filesystem and look at the meminfo "file".
 
You must be careful about setting the heap size parameter. If you set it too low then you will get "out of memory" errors. If you set it too high then your system will hang or you will suffer poor performance because parts of the jvm will be swapped in and out of memory. A rule of thumb is that you should not set this parameter larger than about 80% of your free physical memory. On Windows XP machines you can determine your free physical memory from the Performance tab of the Task Manager application. On Mac machines, click the apple (upper left hand corner and "about this mac"). On Linux machines, you can use the wonderful proc filesystem and look at the meminfo "file".
Line 12: Line 11:
 
The most common source of very slow performance on older systems (or laptops) is having the heap size set too large. If your system does not have 100MB of free memory then even the Protege default value is too big and you should make it smaller (or buy more memory).  
 
The most common source of very slow performance on older systems (or laptops) is having the heap size set too large. If your system does not have 100MB of free memory then even the Protege default value is too big and you should make it smaller (or buy more memory).  
  
 +
The best way to know if you have succeeded in changing the memory settings is to look at the console when Protege starts up.  Protege  will print out the memory settings as they start. The console or the log during startup will look something like this:
 +
<pre>
 +
INFO  11:34:25  ------------------------------------ Protege -----------------------------------
 +
  INFO  11:34:25  Protege Desktop
 +
  INFO  11:34:25  Version 5.5.0, Build
 +
  INFO  11:34:25 
 +
  INFO  11:34:25 
 +
  INFO  11:34:25  ----------------------------------- Platform -----------------------------------
 +
  INFO  11:34:25  Java: JVM 1.8.0_121-b13  Memory: 2237M
 +
  INFO  11:34:25  Language: en, Country: US
 +
  INFO  11:34:25  Framework: Apache Software Foundation (1.8)
 +
  INFO  11:34:25  OS: macosx (10.16)
 +
  INFO  11:34:25  Processor: x86-64
  
There are several ways of setting the heap size depending on how you run Protege.
+
</pre>
 +
 
 +
There are several ways of setting the heap size depending on how you run Protege.  Note that for 64 bit windows machines there is a but in InstallAnywhere that prevents the user from setting the heap size over something like 1.5G.  So in this case you will have to set up the run.bat script method of starting Protege.
  
 
__TOC__
 
__TOC__
Line 20: Line 34:
 
==== Start Protege by Protege.exe/Protege or by double-cliking on the Protege icon (Windows/Linux) ====
 
==== Start Protege by Protege.exe/Protege or by double-cliking on the Protege icon (Windows/Linux) ====
  
If you start Protege on a Windows/Linux machine by double clicking on the Protege.exe/Protege or the Protege icon, you need to update the Protege.lax file.
+
Michael DeBellis wrote on 2021/12/22:
  
By default the Protege.lax file specifies a heap of 100MB for Protege 3.x and 200MB for Protege 4.
+
<start>
 +
Needing more memory for Desktop Protege is a common issue and there is a simple solution. In the main directory where you have Protege [version 5.5 in 2021] there should be a file called Protege.I4J.ini That file is what Protege looks at when it starts up to determine how much memory Java can allocate. If you edit that file in Notepad or some other lightweight text processor it should currently look like this:
  
 +
-Xms200M
 +
-Xmx500M
 +
-Xss16M
  
For '''Protege 3.x''' you can do this in the Protege UI.
+
Xmx is the one you want to edit (I would recommend you make a copy of the original file first). That specifies the maximum amount of memory Protege can use. Xms is the initial memory that will be allocated and Xss defines the increments used when allocating more memory. The main thing to keep in mind is not to allocate so much memory that it starts to limit the performance of other programs which of course depends on how much memory your desktop or laptop have.  
* Go to '''File -> Preferences menu -> Protege.lax'''
+
<end>
* Update the second column of the row containing <code>lax.nl.java.option.java.heap.size.max</code>
 
* Click on OK
 
  
Please note that the changes take effect the next time you start Protege.
+
==== Start Protege by double-clicking on the Protege icon (Mac) ====
  
Below is a screenshot of the Protege.lax panel.
+
If you run Protege on a Mac by double clicking an icon, you need to edit the Info.plist file that is hidden within that icon.  Right click the icon (or ^-click for one button mouses) and click "show package contents".  A new finder window will come up.  Double click "Contents" and then "Info.plist".  Traverse down the tree as follows: "Root" --> "Java" --> "JVMOptions".  In JVMOptions edit the -Xmx line to indicate the correct memory usage. (Add the line <string>-Xmx2400M</string> if it's not there initially.)
 +
        <key>JVMOptions</key>
 +
        <array>
 +
            <string>-Dapple.laf.useScreenMenuBar=true</string>
 +
            <string>-Xss16M</string>
 +
            <string>-Xms500M</string>
 +
            <string>-Xmx1400M</string>
  
  
[[Image:Preferences-protege.lax.png]]
+
==== Start Protege by double-clicking on the applescript file (Mac) ====
  
 +
If you run Protege on a Mac by double clicking the applescript file then you need to modify the -Xmx line in the script.
  
For '''Protege 4''', you must edit directly the Protege.lax file in a text editor.
 
  
Edit the following line in the Protege.lax file in the Protege installation directory:
+
==== Start Protege from the command line ====
  
    lax.nl.java.option.java.heap.size.max=100000000
+
To run Protege from the command line, write in a terminal:
  
==== Start Protege by double-clicking on the Protege icon (Mac) ====
+
.\run.sh
  
If you run Protege on a Mac by double clicking an icon, you need to edit the Info.plist file that is hidden within that icon. Right click the icon (or ^-click for one button mouses) and click "show package contents". A new finder window will come up. Double click "Contents" and then "Info.plist". Traverse down the tree as follows: "Root" --> "Java" --> "VMOptions". In VMOptions edit the -Xmx line to indicate the correct memory usage.
+
(or, if on Windows, <code>run.bat</code>). You may change the heap size by editing the run script in a text editor, and change the value of the <code>-Xmx</code> argument. For example, to start with a 500MB heap size, use <code>-Xmx500M</code>. Read more on setting the heap size as an argument for generic Java applications [https://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html here] and [http://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/index.html here].
  
 +
Note that on Windows machines if you have installed the version of Protege that comes with its own jvm, you may need to change the path to java to jre\bin\java.exe.  So for instance, to get 2G of heap space, you might change the Protege 5.5 run.bat file to be:
  
==== Start Protege by double-clicking on the applescript file (Mac) ====
+
<code>jre\bin\java -Xmx2G -Xms200M -Xss16M -XX:CompileCommand=exclude,javax/swing/text/GlyphView,getBreakSpot -DentityExpansionLimit=100000000 -Dlogback.configurationFile=conf/logback-win.xml -Dfile.encoding=utf-8 -Dorg.protege.plugin.dir=plugins -classpath bundles/guava.jar;bundles/logback-classic.jar;bundles/logback-core.jar;bundles/slf4j-api.jar;bin/org.apache.felix.main.jar;bin/maven-artifact.jar;bin/protege-launcher.jar org.protege.osgi.framework.Launcher %1
 
+
</code>
If you run Protege on a Mac by double clicking the applescript file then you need to modify the -Xmx line in the script.
 
 
 
 
 
==== Start Protege from the command line ====
 
 
 
If you run Protege from the java command line then you need to pass in the heap size with the -Xmx command line switch. Example, if you want to run Protege with 500 MB of heap size, you would specify:
 
  
<code>-Xmx500M</code>
 
  
 
[[Category:Protege documentation]]
 
[[Category:Protege documentation]]

Latest revision as of 20:59, February 17, 2022

Setting the Heap Size


Recommendations for setting the heap size (read first!)


You must be careful about setting the heap size parameter. If you set it too low then you will get "out of memory" errors. If you set it too high then your system will hang or you will suffer poor performance because parts of the jvm will be swapped in and out of memory. A rule of thumb is that you should not set this parameter larger than about 80% of your free physical memory. On Windows XP machines you can determine your free physical memory from the Performance tab of the Task Manager application. On Mac machines, click the apple (upper left hand corner and "about this mac"). On Linux machines, you can use the wonderful proc filesystem and look at the meminfo "file".

Boosting the heap size parameter will allow you to read in larger file-based projects. It will also improve the performance of the database back-end since more memory is available for caching.

The most common source of very slow performance on older systems (or laptops) is having the heap size set too large. If your system does not have 100MB of free memory then even the Protege default value is too big and you should make it smaller (or buy more memory).

The best way to know if you have succeeded in changing the memory settings is to look at the console when Protege starts up. Protege will print out the memory settings as they start. The console or the log during startup will look something like this:

INFO  11:34:25  ------------------------------------ Protege -----------------------------------
   INFO  11:34:25  Protege Desktop
   INFO  11:34:25  Version 5.5.0, Build 
   INFO  11:34:25  
   INFO  11:34:25  
   INFO  11:34:25  ----------------------------------- Platform -----------------------------------
   INFO  11:34:25  Java: JVM 1.8.0_121-b13  Memory: 2237M
   INFO  11:34:25  Language: en, Country: US
   INFO  11:34:25  Framework: Apache Software Foundation (1.8) 
   INFO  11:34:25  OS: macosx (10.16)
   INFO  11:34:25  Processor: x86-64

There are several ways of setting the heap size depending on how you run Protege. Note that for 64 bit windows machines there is a but in InstallAnywhere that prevents the user from setting the heap size over something like 1.5G. So in this case you will have to set up the run.bat script method of starting Protege.


Start Protege by Protege.exe/Protege or by double-cliking on the Protege icon (Windows/Linux)

Michael DeBellis wrote on 2021/12/22:

<start> Needing more memory for Desktop Protege is a common issue and there is a simple solution. In the main directory where you have Protege [version 5.5 in 2021] there should be a file called Protege.I4J.ini That file is what Protege looks at when it starts up to determine how much memory Java can allocate. If you edit that file in Notepad or some other lightweight text processor it should currently look like this:

-Xms200M -Xmx500M -Xss16M

Xmx is the one you want to edit (I would recommend you make a copy of the original file first). That specifies the maximum amount of memory Protege can use. Xms is the initial memory that will be allocated and Xss defines the increments used when allocating more memory. The main thing to keep in mind is not to allocate so much memory that it starts to limit the performance of other programs which of course depends on how much memory your desktop or laptop have. <end>

Start Protege by double-clicking on the Protege icon (Mac)

If you run Protege on a Mac by double clicking an icon, you need to edit the Info.plist file that is hidden within that icon. Right click the icon (or ^-click for one button mouses) and click "show package contents". A new finder window will come up. Double click "Contents" and then "Info.plist". Traverse down the tree as follows: "Root" --> "Java" --> "JVMOptions". In JVMOptions edit the -Xmx line to indicate the correct memory usage. (Add the line <string>-Xmx2400M</string> if it's not there initially.)

       <key>JVMOptions</key>
       <array>
           <string>-Dapple.laf.useScreenMenuBar=true</string>
           <string>-Xss16M</string>
           <string>-Xms500M</string>
           <string>-Xmx1400M</string>


Start Protege by double-clicking on the applescript file (Mac)

If you run Protege on a Mac by double clicking the applescript file then you need to modify the -Xmx line in the script.


Start Protege from the command line

To run Protege from the command line, write in a terminal:

.\run.sh

(or, if on Windows, run.bat). You may change the heap size by editing the run script in a text editor, and change the value of the -Xmx argument. For example, to start with a 500MB heap size, use -Xmx500M. Read more on setting the heap size as an argument for generic Java applications here and here.

Note that on Windows machines if you have installed the version of Protege that comes with its own jvm, you may need to change the path to java to jre\bin\java.exe. So for instance, to get 2G of heap space, you might change the Protege 5.5 run.bat file to be:

jre\bin\java -Xmx2G -Xms200M -Xss16M -XX:CompileCommand=exclude,javax/swing/text/GlyphView,getBreakSpot -DentityExpansionLimit=100000000 -Dlogback.configurationFile=conf/logback-win.xml -Dfile.encoding=utf-8 -Dorg.protege.plugin.dir=plugins -classpath bundles/guava.jar;bundles/logback-classic.jar;bundles/logback-core.jar;bundles/slf4j-api.jar;bin/org.apache.felix.main.jar;bin/maven-artifact.jar;bin/protege-launcher.jar org.protege.osgi.framework.Launcher %1