M
Malcolm Klotz
Hello,
I have created a Windows Service application in VB.Net 2005. The service is
pretty basic, it uses the System.Timers.Timer class to poll a database that
checks for jobs to perform. Upon finding a job, the
System.Timers.ElapsedEventHandler creates a new thread to execute the job.
The job is pretty basic, it uses and xml document and applies it to an XSLT
document using the XSLTransform class.
After this services runs a job the memory doubles, and keeps on doubling
until it finally crashes on memory. When I profiled this application, I
noticed the the Byte[] class was holding the most memory, and was surviving
all subsequent garbage collections. I pinned the Byte[] to the following
method:
Private _XSLTDocument As Xml.Xsl.XslTransform
Private Sub InitializeTemplate(ByVal aXSLTLocation As String)
Dim xsltFileSpec As String
If IO.File.Exists(aXSLTLocation) Then
_XSLTDocument = New Xml.Xsl.XslTransform
_XSLTDocument.Load(xsltFileSpec, New Xml.XmlUrlResolver)
Else
Throw New IO.FileNotFoundException(String.Format("No XLS
Transform document was found at: {0}.", xsltFileSpec))
End If
End Sub
It appears (to me) that the XSLTransform class is not being collected or is
not releasing the memory it occupies. I have impliemented the IDosposable
interface for the class that holds this method (although, I do not see why
it was needed, but I was trying to fix the problem). I have made sure that
the thread the this class runs on is indeed at a stopped state when
completed. I have exhausted my potentional, any help here would be
appreciated.
Bottom line: Why is the the Load method on the class XSLTransform taking up
so much memory, and how do I release it?
Thanks.
Malcolm Klotz
I have created a Windows Service application in VB.Net 2005. The service is
pretty basic, it uses the System.Timers.Timer class to poll a database that
checks for jobs to perform. Upon finding a job, the
System.Timers.ElapsedEventHandler creates a new thread to execute the job.
The job is pretty basic, it uses and xml document and applies it to an XSLT
document using the XSLTransform class.
After this services runs a job the memory doubles, and keeps on doubling
until it finally crashes on memory. When I profiled this application, I
noticed the the Byte[] class was holding the most memory, and was surviving
all subsequent garbage collections. I pinned the Byte[] to the following
method:
Private _XSLTDocument As Xml.Xsl.XslTransform
Private Sub InitializeTemplate(ByVal aXSLTLocation As String)
Dim xsltFileSpec As String
If IO.File.Exists(aXSLTLocation) Then
_XSLTDocument = New Xml.Xsl.XslTransform
_XSLTDocument.Load(xsltFileSpec, New Xml.XmlUrlResolver)
Else
Throw New IO.FileNotFoundException(String.Format("No XLS
Transform document was found at: {0}.", xsltFileSpec))
End If
End Sub
It appears (to me) that the XSLTransform class is not being collected or is
not releasing the memory it occupies. I have impliemented the IDosposable
interface for the class that holds this method (although, I do not see why
it was needed, but I was trying to fix the problem). I have made sure that
the thread the this class runs on is indeed at a stopped state when
completed. I have exhausted my potentional, any help here would be
appreciated.
Bottom line: Why is the the Load method on the class XSLTransform taking up
so much memory, and how do I release it?
Thanks.
Malcolm Klotz