On Fri, 2003-05-23 at 13:56, Jon Brisbin wrote: 
> If someone else has found a way to do anything meaningful over an
> extended period of time (i.e. not one transform per minute, like in
> many testing and development situations) without having a bare minimum
> of 1-2 GBs of RAM, I'd be interested to hear your solution.  

I have an application (in production) which is long-running, and does
XSLT transforms using Xalan. I am running it with the IBM 1.4 JVM on
AIX.

At the current time, it:
* has been running for 3 days (3*24 hours)
* has processed 5980 messages (each message involves at least one
DOM-to-DOM transform)

The JVM has been given permission to use 256MB (startup parameters), but
has only ever allocated 96MB of that, at peak.

The stylesheets are of moderate complexity, and the input documents
range from 100bytes to 1MB in size.

Typically, the allocated amount is around 80MB, of which around 50MB is
used [see below] and 30MB free.

These numbers seem quite different from yours!

I do take a fairly simple approach to performing XSL translations. I
reload the stylesheet and recreate the Transformer instance each time, 
mainly because this is fast enough for me; I don't wish to optimise
until there is a reason to. Having said that, performing such an
optimisation is on the plan long-term.


How exactly are you measuring memory usage?

Remember that the amount of memory allocated by the OS to the JVM is
really almost irrelevant. What really matters is the "working set size",
ie the number of pages which are accessed frequently. If the JVM
allocates memory pages but does not use them, then they get flushed out
to the swap space, and have essentially no effect on the host machine at
all. I think the best available measure of *actual, relevant* memory
usage by the JVM is the value returned by:
  java.lang.Runtime.totalMemory() - java.lang.Runtime.freeMemory().
This is how I calculate the "used" statistic quoted above.

If the JVM needs more memory than it currently has allocated, but is
below its max threshold, then it will grow its heap by allocating more
memory from the OS. If its memory usage later drops, I don't see any
urgent reason why it should release that extra memory..if the memory is
allocated but not being actively accessed, then it will just sit
"dormant" in the swap space, doing the host OS no harm.

I am assuming here that the JVM is smart enough to try to keep its
allocated objects in a fairly compact area rather than letting them get
scattered across the entire available memory area.

Any corrections/comments welcome.

Regards,

Simon

Reply via email to