I don't think its just garbage collection.  The call to transformer.transform doesn't free all the memory that it uses up.  I expected it to do its thing and then free up all the temporary structures used after it has finished.  It is not a memory leak though because it doesn't keep using more and more each time I call it with the same document but instead reaches a limit, so it must be some sort of deliberate cache.
 
The memory is an issue for me because it slows the whole process down heaps which defeats the purpose of using the same Templates object to process multiple documents in the first place.  (This is just running on a desktop PC with 0.5Gb RAM and after running a few documents through this the process is using over 300Mb which is never releases, and this causes it to start running very slowly.)
 
Its not a problem that the memory usage gets high while it is running but I would like it to drop back down after the transfromation has finished.  Any ideas?
 
Thanks, Damon

 -----Original Message-----
From: Jon Brisbin [mailto:[EMAIL PROTECTED]
Sent: Friday, 23 May 2003 11:19 a.m.
To: Damon Horrell; [EMAIL PROTECTED]
Subject: RE: Reusing Templates doesn't free memory

 
I recently worked on a large-scale XML and XSLT application framework and one of the things we've found is that the garbage collector can be a problem when it comes to using XSLT in a large application with loads of requests.  You may end up having to use a thread-safe object that reuses things as much as possible.  It's a pain, I know, but it seems to help.  You should also DEFINATELY tweak your JVM settings to fiddle with the heap size.  If you don't, don't be surprised to start seeing OutOfMemory errors as your applications and transformations get larger.
 
BTW-  100 MBs of memory usage in a nice-sized XSLT application is really not that much :-)  If I could keep the memory usage under 100 MBs on my framework application under even moderate load, I'd be tickled! :-)  Under a heavy load, I was able to push memory usage up to about 1.5 GBs, sustained :-)

Thanks!

Jon Brisbin
=+=+=+=+=+=+=+=+=+=+=+=
www.jbrisbin.net
417.682.6157 (h/o)
417.850.1644 (cel)
 

-----Original Message-----
From: Damon Horrell [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 22, 2003 6:08 PM
To: '[EMAIL PROTECTED]'
Subject: Reusing Templates doesn't free memory

Hi,
 
I have written a little server program that uses a Templates object to avoid reparsing my XSLT each time I want to process a document.  I am finding that it chews up an awful lots of memory (like 100+ Mb) though which does not get released when the transformation is finished.  If I process the same document a few times the memory increases and then remains static after about the 3rd time, but it grows higher still if I process other documents.
 
I am not sure if this is because it is caching the source document or something. I have experimented with noth XPathContext.release and SourceTreeManager but to no effect.
 
I don't want anything other than the Templates object to be retained in memory after each transformation is run.
 
Does anybody know where the memory goes and how I can release it?
 
Has anyone else sucessfully written a similar application to efficiently process multiple source documents through the same transformation?
 
Thanks, Damon
 

Reply via email to