view java-settings.html @ 1642:636e7342b1b6

Creating site for 2.5-SNAPSHOT
author Robert Casties <casties@mpiwg-berlin.mpg.de>
date Tue, 22 Aug 2017 18:46:51 +0000
parents 16be3440305b
children fe8300fdcd9d
line wrap: on
line source

<!DOCTYPE html>
<!--
 | Generated by Apache Maven Doxia at 2017-08-22
 | Rendered using Apache Maven Fluido Skin 1.3.0
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="Date-Revision-yyyymmdd" content="20170822" />
    <meta http-equiv="Content-Language" content="en" />
    <title>digilib - The Digital Image Library &#x2013; Java VM memory settings for digilib</title>
    <link rel="stylesheet" href="./css/apache-maven-fluido-1.3.0.min.css" />
    <link rel="stylesheet" href="./css/site.css" />
    <link rel="stylesheet" href="./css/print.css" media="print" />

      
    <script type="text/javascript" src="./js/apache-maven-fluido-1.3.0.min.js"></script>

    
            </head>
        <body class="topBarDisabled">
          
        
    
        <div class="container-fluid">
          <div id="banner">
        <div class="pull-left">
                                    <a href="https://robcast.github.io/digilib/" id="bannerLeft">
                <h2>digilib - a versatile image viewing environment for the internet</h2>
                </a>
                      </div>
        <div class="pull-right">                  <a href="https://robcast.github.io/digilib/" id="bannerRight">
                                                                                                <img src="images/digilib-logo-small.png" />
                </a>
      </div>
        <div class="clear"><hr/></div>
      </div>

      <div id="breadcrumbs">
        <ul class="breadcrumb">
                
                    
                  <li id="publishDate">Last Published: 2017-08-22</li>
                  <li class="divider">|</li> <li id="projectVersion">Version: 2.5-SNAPSHOT</li>
                      
                
                    
      
                            </ul>
      </div>

            
      <div class="row-fluid">
        <div id="leftColumn" class="span3">
          <div class="well sidebar-nav">
                
                    
                <ul class="nav nav-list">
                    <li class="nav-header">Overview</li>
                                
      <li>
    
                          <a href="index.html" title="About digilib">
          <i class="none"></i>
        About digilib</a>
            </li>
                  
      <li>
    
                          <a href="features.html" title="digilib features">
          <i class="none"></i>
        digilib features</a>
            </li>
                  
      <li>
    
                          <a href="digilib-short.html" title="How digilib works">
          <i class="none"></i>
        How digilib works</a>
            </li>
                  
      <li>
    
                          <a href="history.html" title="Ancient history">
          <i class="none"></i>
        Ancient history</a>
            </li>
                              <li class="nav-header">Installation</li>
                                
      <li>
    
                          <a href="install-digilib.html" title="Installing digilib">
          <i class="none"></i>
        Installing digilib</a>
            </li>
                  
      <li>
    
                          <a href="build-maven.html" title="Building digilib">
          <i class="none"></i>
        Building digilib</a>
            </li>
                              <li class="nav-header">Configuration</li>
                                
      <li>
    
                          <a href="digilib-config.html" title="Configuring digilib">
          <i class="none"></i>
        Configuring digilib</a>
            </li>
                  
      <li>
    
                          <a href="image-directories.html" title="Directory layout">
          <i class="none"></i>
        Directory layout</a>
            </li>
                  
      <li class="active">
    
            <a href="#"><i class="none"></i>Java settings and tuning</a>
          </li>
                  
      <li>
    
                          <a href="auth.html" title="Access control">
          <i class="none"></i>
        Access control</a>
            </li>
                              <li class="nav-header">Development</li>
                                
      <li>
    
                          <a href="scaler-api.html" title="The digilib Scaler API">
          <i class="none"></i>
        The digilib Scaler API</a>
            </li>
                  
      <li>
    
                          <a href="iiif-api.html" title="The digilib IIIF API">
          <i class="none"></i>
        The digilib IIIF API</a>
            </li>
                  
      <li>
    
                          <a href="client-integration.html" title="Integrating digilib into your page">
          <i class="none"></i>
        Integrating digilib into your page</a>
            </li>
                  
      <li>
    
                          <a href="plugins.html" title="Digilib plugins">
          <i class="none"></i>
        Digilib plugins</a>
            </li>
                              <li class="nav-header">Project Documentation</li>
                                                                                                                                                          
      <li>
    
                          <a href="project-info.html" title="Project Information">
          <i class="icon-chevron-right"></i>
        Project Information</a>
                  </li>
            </ul>
                
                    
                
          <hr class="divider" />

           <div id="poweredBy">
                            <div class="clear"></div>
                            <div class="clear"></div>
                            <div class="clear"></div>
                                                                                                                   <a href="http://maven.apache.org/" title="Built by Maven" class="builtBy">
        <img class="builtBy"  alt="Built by Maven" src="https://maven.apache.org/images/logos/maven-feather.png"    />
      </a>
                                                                                                    <a href="https://github.com/" title="Hosted by GitHub" class="builtBy">
        <img class="builtBy"  alt="Hosted by GitHub" src="https://assets-cdn.github.com/images/modules/logos_page/GitHub-Logo.png"   width="200px"  />
      </a>
                                                                                                    <a href="http://www.sourceforge.net/" title="Hosted by SourceForge" class="builtBy">
        <img class="builtBy"  alt="Hosted by SourceForge" src="https://upload.wikimedia.org/wikipedia/commons/0/0b/Sourceforge_logo.png"    />
      </a>
                      </div>
          </div>
        </div>
        
                
        <div id="bodyColumn"  class="span9" >
                                  
            <h1>Java VM memory settings for digilib</h1>
<p>(Robert Casties, September 2013)</p>
<p>The Java virtual machine (Java-VM) only uses a fixed amount of memory for its operations. When an operation needs more memory than available it aborts with an error (&#x201c;out of memory error&#x201d;).</p>
<p>digilib can need a lot of memory depending on the size and type of images. Since digilib runs as a servlet under Tomcat its in the same VM as the Tomcat server.</p>
<p>The amount of memory Tomcat (version 5.0) uses is configured by creating a <tt>setenv.sh</tt> (or <tt>setenbv.bat</tt>) script with a line</p>

<div class="source">
<div class="source">
<pre>CATALINA_OPTS=&quot;-Xmx512m&quot;
</pre></div></div>
<p>in Tomcat&#x2019;s <tt>bin</tt> directory (giving 512MB RAM in this case).</p>
<p>You can check the amount of memory your digilib instance has available on the bottom of the web page <tt>/server/dlConfig.jsp</tt> in your digilib instance (e.g. <a class="externalLink" href="http://localhost:8080/digilib/server/dlConfig.jsp">http://localhost:8080/digilib/server/dlConfig.jsp</a></p>
<h1>Installing JAI ImageIO</h1>
<p>(Robert Casties, September 2013)</p>
<p>In principle you should be able to install the <a class="externalLink" href="http://java.sun.com/javase/technologies/desktop/media/jai/">Java Advanced Imaging</a> JAI-ImageIO JAR file <tt>jai_imageio.jar</tt> (and native library files if available) in the <tt>/WEB-INF/lib/</tt> directory of the digilib web application as part of the default installation.</p>
<p>You can see if the Jai-ImageIO plugin is active by checking for the availability of the TIFF image format under &#x201c;Supported image types&#x201d; on the <a class="externalLink" href="http://localhost:8080/digilib/server/dlConfig.jsp"><tt>/server/dlConfig.jsp</tt></a> status page.</p>
<p>Sometimes there are problems with leaking memory. Newer versions of Tomcat refuse to load the libraries (see JREMemoryLeakPreventionListener) and I found that in some cases digilib stopped reading TIFF files after a period of running. In these cases it helped to install the JAI files in Tomcats <tt>lib/</tt> directory or globally in the local Java JDK installation (i.e. in the Java&#x2019;s &#x2018;jre/lib/ext/&#x2019; directory on linux).</p>
<p>If you really need to have the imageio-plugins JAR inside the web app, please consider using Harald Kuhrs <a class="externalLink" href="https://github.com/haraldk/TwelveMonkeys#deploying-the-plugins-in-a-web-app">IIOProviderContextListener</a>.</p>
<h1>Codec availability and Performance</h1>
<p>(Ubbo Veentjer, Oct 2015)</p>
<p>The number of image formats, which digilib may read or write, but also the performance of operating on this image formats depends on the ImageIO readers and writers available on the classpath.</p>
<p>Working with larger images in JPEG format we experienced a big performance difference using different implementations of the JPEG readers/writers. OpenJDK-7 for example brings rather slow JPEG codecs, OpenJDK-8 operates much quicker on JPEG images, relying on libjpeg-turbo for this file format. Also the official Oracle-JDKs may include faster native codecs. </p>
<p>Some drop-in replacements for the native codecs are:</p>

<ul>
  
<li><a class="externalLink" href="https://github.com/geosolutions-it/imageio-ext">https://github.com/geosolutions-it/imageio-ext</a></li>
  
<li><a class="externalLink" href="https://github.com/haraldk/TwelveMonkeys">https://github.com/haraldk/TwelveMonkeys</a></li>
</ul>
<p>if these jar files are availabe on the classpath, the codecs may be used by digilib. To add them the jar files could e.g. be placed in the lib directory of tomcat or addded as a dependency to the digilib maven project.</p>
<p>The actual codec implementation used is logged by digilib in debug mode, e.g.</p>

<div class="source">
<div class="source">
<pre>1564059 [http-apr-9092-exec-4] DEBUG digilib.image.DocuImage  - ImageIO: this reader: class com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReader
</pre></div></div>
<p>(Robert Casties, Oct 2015)</p>
<p>You can now use the TwelveMonkeys codecs instead of the default JAI-ImageIO by just <a href="build-maven.html">building digilib</a> with the Maven-Parameter <tt>imageio=12m</tt>:</p>

<div class="source">
<div class="source">
<pre>mvn -Dimageio=12m package
</pre></div></div>
<h1>Codec performance</h1>
<p>(Ubbo Veentjer, Oct 2015)</p>
<p>In our tests comparing the performance of OpenJDK7, OpenJDK8, imageio-ext and TwelveMonkeys codecs we experienced the following numbers for decoding, encoding and scaling a 4968px*5968px JPEG file with a color profile to 50% size: </p>

<div class="source">
<div class="source">
<pre>24801 ms - OpenJDK7
11507 ms - OpenJDK7 with com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReader
4216 ms - OpenJDK7 with imageio-ext using libjpeg-turbo
3635 ms - OpenJDK8 
</pre></div></div>
<p>This numbers may depend on the actual implementation used, the processing power of the CPU and many other factors, to this is just meant to be a rough hint.</p>
<p>For using imageio-ext, the native library needs to be available with the <tt>LD_LIBRARY_PATH</tt> environment variable (compare: <a class="externalLink" href="https://github.com/geosolutions-it/imageio-ext/wiki/TurboJPEG-plugin)">https://github.com/geosolutions-it/imageio-ext/wiki/TurboJPEG-plugin)</a>, also the .jar archives need to be on the classpath.</p>
<p>For using the TwelveMonkey Codecs we added the following jars to the tomcat lib directory, which were retrieved by maven (dependency on imageio-jpeg-3.1.2):</p>

<ul>
  
<li>common-image-3.1.2.jar</li>
  
<li>common-lang-3.1.2.jar</li>
  
<li>imageio-jpeg-3.1.2.jar</li>
  
<li>common-io-3.1.2.jar</li>
  
<li>imageio-core-3.1.2.jar</li>
  
<li>imageio-metadata-3.1.2.jar</li>
</ul>
<h1>Available image formats</h1>
<p>(Ubbo Veentjer, Oct 2015)</p>
<p>Digilib logs on startup which image formats are supported, e.g: </p>

<div class="source">
<div class="source">
<pre>9763 [localhost-startStop-1] INFO digilib.conf.DigilibConfiguration  - DocuImage supported image formats: raw, jpeg, tif, WBMP, pcx, PNM, JPG, wbmp, JPEG, PNG, jpeg 2000, tiff, BMP, JPEG2000, RAW, jpeg2000, GIF, TIF, TIFF, bmp, jpg, PCX, pnm, png, gif,
</pre></div></div>
<p>by adding e.g. TwelveMonkeys or image-io ext codecs, more codecs could become available.</p>
                  </div>
            </div>
          </div>

    <hr/>

    <footer>
            <div class="container-fluid">
              <div class="row span12">Copyright &copy;                    2001-2017
                        <a href="https://github.com/robcast/digilib">digilib Community</a>.
            All Rights Reserved.      
                    
      </div>

        
        
                </div>
    </footer>
  </body>
</html>