Difference between revisions of "Setting Heap Size"

From Protege Wiki
Jump to: navigation, search
Line 22: Line 22:
 
</pre>
 
</pre>
  
There are several ways of setting the heap size depending on how you run Protege.
+
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 65: Line 65:
 
==== Start Protege from the command line ====
 
==== 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:
+
If you run Protege from the java command line (run.bat, run.sh) 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>
 
<code>-Xmx500M</code>
 +
 +
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 4.2 run.bat file to be:
 +
 +
<code>jre\bin\java.exe -Xmx2G -Dlog4j.configuration=file:log4j.xml -DentityExpansionLimit=100000000 -Dfile.encoding=utf-8 -Dorg.protege.plugin.dir=plugins -classpath bin/felix.jar;bin/ProtegeLauncher.jar org.protege.osgi.framework.Launcher</code>
 +
  
 
[[Category:Protege documentation]]
 
[[Category:Protege documentation]]

Revision as of 10:41, April 5, 2012

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. Both Protege 3 and Protege 4 will print out the memory settings as they start. The format is slightly different for Protege 3 and Protege 4 but the console during startup will look something like this:

Starting Protege 4 OWL Editor (Version 4.1.0, Build = 231)
Platform:
    Java: JVM 1.6.0_18-b07 Memory: 2229M
    Language: en, Country: US
    Framework: Apache Software Foundation (1.5)
    OS: linux (2.6.38-8-generic)
    Processor: x86

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)

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.

By default the Protege.lax file specifies a heap of 100MB for Protege 3.x and 200MB for Protege 4.


For Protege 3.x you can do this in the Protege UI.

  • Go to File -> Preferences menu -> Protege.lax
  • Update the second column of the row containing lax.nl.java.option.java.heap.size.max
  • Click on OK

Please note that the changes take effect the next time you start Protege.

Below is a screenshot of the Protege.lax panel.


Preferences-protege.lax.png


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:

   lax.nl.java.option.java.heap.size.max=100000000

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" --> "VMOptions". In VMOptions edit the -Xmx line to indicate the correct memory usage.


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

If you run Protege from the java command line (run.bat, run.sh) 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:

-Xmx500M

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 4.2 run.bat file to be:

jre\bin\java.exe -Xmx2G -Dlog4j.configuration=file:log4j.xml -DentityExpansionLimit=100000000 -Dfile.encoding=utf-8 -Dorg.protege.plugin.dir=plugins -classpath bin/felix.jar;bin/ProtegeLauncher.jar org.protege.osgi.framework.Launcher