You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Justin M Wozniak <jw...@cse.nd.edu> on 2006/11/06 06:03:38 UTC

Garbage Collection of DocumentImpl, SAXParser

I'm having a garbage collection problem.  I have a small server
application that parses Strings to build XML Documents using an
effectively global Transformer.  Using jmap, I noticed that these
DocumentImpl, SAXParser, etc. instances are not being garbage collected
even when other objects are, causing eventual memory problems.  After
processing these Documents definitely fall out of scope; the receiving
class is garbage collected.  Does the Transformer or some other object
hold on to these Documents?

Using JDK 1.5.0.

I'm doing this in a helper class:

  public static Document parse(String s)
  {
    Document doc = builder.newDocument();

    try
    {
      StringReader sr     = new StringReader(s);
      StreamSource source = new StreamSource(sr);
      DOMResult result = new DOMResult(doc);
      transformer.transform(source, result);
      sr.close();
    }


-- 
Justin Michael Joseph Wozniak

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Garbage Collection of DocumentImpl, SAXParser

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Justin M Wozniak <jw...@cse.nd.edu> wrote on 11/06/2006 12:03:38 AM:

> I'm having a garbage collection problem.  I have a small server
> application that parses Strings to build XML Documents using an
> effectively global Transformer.  Using jmap, I noticed that these
> DocumentImpl, SAXParser, etc. instances are not being garbage collected
> even when other objects are, causing eventual memory problems.  After
> processing these Documents definitely fall out of scope; the receiving
> class is garbage collected.  Does the Transformer or some other object
> hold on to these Documents?

Perhaps. You should ask this question on one of the Xalan mailing lists.

> Using JDK 1.5.0.

If you're using the parser/transformer in JDK 5.0 you're using Sun's (2 to 
3 year old) fork of Xerces/Xalan. It's possible the issue you're having 
has long been fixed or never existed in Apache.

> I'm doing this in a helper class:
> 
>   public static Document parse(String s)
>   {
>     Document doc = builder.newDocument();
> 
>     try
>     {
>       StringReader sr     = new StringReader(s);
>       StreamSource source = new StreamSource(sr);
>       DOMResult result = new DOMResult(doc);
>       transformer.transform(source, result);
>       sr.close();
>     }
> 
> 
> -- 
> Justin Michael Joseph Wozniak
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org