Hi Folks,

I've completed my application and am investigating massive memory 
demands (100M - 300M). The following are some of my conclusions, which 
may be of use to others. I'm definitely not an expert so comments please 
from those that know better. Some of the following does seems to 
contradict other posting about memory configuration.

The java heap is the area of RAM reserved for use by the java virtual 
machine. At any time only part of the heap will be in use. The size of 
the part in use will vary over time as classes and instances are loaded 
and released. If the size in use approaches the size of the heap, then 
more memory will be allocated to the heap. If the amount in use falls to 
a small percentage of the heap size for a relatively long period the 
size of the heap will be reduced by the jvm, to free memory for the 
operating system.

Xms and Xmx are set when the jvm is started. If using Tomcat-4.0.1 set 
the environment parameter CATALINA_OPTS=-Xms<value> -Xmx<value> before 
starting Tomcat.

Xms - sets initial java heap size
---------------------------------
With cocoon there seems to be little point setting this as start-up 
times are dominated by other factors.

Xmx - sets maximum java heap size
---------------------------------
This is the maximum amount of memory available to Tomcat and Cocoon. If 
there is demand for more than is available, then a 
java.lang.outofmemory() exception will occur - to be avoided at all 
costs!!! I've found it best to set this to a size which leaves some RAM 
for the operating system. If there is virtual memory configured on the 
operating system (hard disk pretending to be RAM) then set the maximum 
jvm heap low enough to avoid using it.

Store Janitor
-------------
In the cocoon.xconf file there are setting for the store-janitor. The 
store, I think, is a file cache run by cocoon which therefore places 
demands on the jvm heap. These setting control the size of the file 
cache to stop it using up all of the heap and thereby causing a 
java.lang.outofmemory() error.

   <store-janitor 
class="org.apache.cocoon.components.store.StoreJanitorImpl" 
logger="root.store">
      <parameter name="freememory" value="1000000"/>
      <parameter name="heapsize" value="60000000"/>
      <parameter name="cleanupthreadinterval" value="10"/>
      <parameter name="threadpriority" value="5"/>
   </store-janitor>

parameter 'heapsize' - the size of jvm heap below which the file cache 
is allowed to grow. When actual heap size (not heap in use) exceeds this 
size then the store-janitor will take steps to reduce it, assuming the 
amount of actual free memory is below the parameter 'freememory' limit. 
Parameter 'heapsize' must be less than Xmx otherwise the store would be 
allowed to fill the heap. The difference between Xmx and 'heapsize' must 
be sufficient memory for cocoon during a 'cleanupthreadinterval'.

parameter 'freememory' - is the difference between heap size and heap in 
use which the store-janitor must achieve (by giving up memory) if the 
actual heap size has exceeded the parameter 'heapsize'. This is the 
amount of free memory which must be available to cocoon during the 
'cleanupthreadinterval' assuming the heapsize might no longer be able to 
increase. If 'freememory' is set too large, then the store-janitor will 
give up more of its cache than it needs to, or might not be able to free 
sufficient by emptying the file cache.

parameter 'cleanupthreadinterval' - the period in seconds between 
store-janitor's attempts to monitor memory and adjust the store. Also 
triggers finalization and the garbage collector.


My suggested settings for different ram sizes in Megabytes:

            (default)64    128    256    384
                     --    ---    ---    ---
Xms                  0      0      0      0
Xmx                 64    100    228    356
heapsize            60     80    208    236
freememory           1     20     20    20

Note:
----
The difference between Xmx and heapsize is needed to ensure sufficient 
free memory for cocoon during the first cleanupthreadinterval in which 
the actual heap size exceeds 'heapsize'. Similarly the parameter 
'freememory' tells the store-janitor to attempt to clear sufficient 
memory for the next interval. So I've suggested the difference between 
Xms and heapsize be the same as the size of freememory. It might need to 
be bigger on a fast machine, or the interval reduced.


Would the experts please comment on the above. Please let me know if I'm 
on the right lines or if there is anything else I should know about.

Many thanks,
Pete Hargreaves.

P.S. My system is:
Gateway G6-350 (392,612 RAM), NT4.0sp6, jdk-1.3.1, tomcat-4.0.1, cocoon-2.0
Gateway G6-350 (392,612 RAM), RH Linux 7.0, jdk-1.3, tomcat-4.0.1, 
cocoon-2.0



---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to