100% cpu usage in xml/xslt driven asp.net web app?

What version of . NET? It's been a while since I've done anything with it XML/ XSL, but .

NET 2.0 had some memory issues in XslCompiledTransform. While that could be the issue, it's more likely something in the code. Can you provide some sample XML and the XSL doc?

What happens if you save both out as static files and try to run the transform (create a small standalone script or unit test that just does this to see if it's an issue)? Make sure you're disposing of your XslCompiledTransform object as soon as you're done with it (and the XML doc as well) When I run into issues with XSL transforms, I usually save a sample XML document and apply my XSL in Cooktop It's a little hard to figure out at first, but it's a good sanity check to make sure you don't have a glaring error in your XSL.

What version of . NET? It's been a while since I've done anything with it XML/ XSL, but .

NET 2.0 had some memory issues in XslCompiledTransform. While that could be the issue, it's more likely something in the code. Can you provide some sample XML and the XSL doc?

What happens if you save both out as static files and try to run the transform (create a small standalone script or unit test that just does this to see if it's an issue)? Make sure you're disposing of your XslCompiledTransform object as soon as you're done with it (and the XML doc as well). When I run into issues with XSL transforms, I usually save a sample XML document and apply my XSL in Cooktop.It's a little hard to figure out at first, but it's a good sanity check to make sure you don't have a glaring error in your XSL.

The transform is cached for later use (it is used over and over again). I don't specifically do anything with the document after use though, should I set it to null? – aepheus Feb 25 '10 at 20:47 Yes, set = null is what I meant by dispose of it.

Maybe I'm out of date/ out of practice, but while you may be caching the transformed document, the object that you do the transforming with can be disposed of once it's no longer needed, can't it? – Tom Feb 25 '10 at 21:08.

Consider using Linq to XML to do the transformation - 350 kB is a large text/xml document from a transformation standpoint - it might be faster than an XSLT tranformation. See here for a sample.

The transformed documents cannot be cached, they are user specific at that point. The web service is within the network, but not on the same server. – aepheus Feb 25 '10 at 22:35 But "...XslCompiledTransform - stores the transform, is cached in Application...." – Jonathan Feb 25 '10 at 22:47 The xml transforms are on the same server and don't come from a web service, the data xml comes from a different server.

Sorry for any confusion – aepheus Feb 25 '10 at 23:23.

Try to user a Profiler. DotTrace and ANTS have trial versions. This should make you able to pin point your problems.(The nice thing about dotTrace is, that it integrates with unit tests.).

It would take some complicated code to get all the XML together without the ability to write to the XmlDocument. There is additional XML that does not come from the web service that must also be added to the document. Any suggestions would be nice.

The server doesn't seem to be having memory issues, if that is telltale of anything, just really high cpu usage. After much searching I found that the issue causing the cpu to race was actually an infinite (or near) loop, which was not in my code at all, and hidden from my profiling due to the nature of where it was coming up. Lesson here, if it doesn't make sense, look for alternative reasoning for the issue before tearing your code apart.

Related Questions