Next generation's garbage RSS 2.0
# Thursday, October 18, 2007

Last month I was working with some code that used System.Xml.Xsl.XslCompiledTransform. I knew it involved compiling stuff (where did I get that idea?) and making some IL dynamically to run. Neat-o. This month on my road to getting MCPD by month-end, I was reading about RegEx. It didn't really dawn on me before that it could compile the expression vs. interpret it. Pretty cool. But I was always skeptical about these because I had heard that you can Assembly.Load, but there's no such thing as Assembly.Unload... so I thought that this meant these would be memory leaks... but, no. I read (http://blogs.msdn.com/joelpob/archive/2004/04/01/105862.aspx) about something called LGC (lightweight code-gen) and DynamicMethod. I was reading this (http://blogs.msdn.com/bclteam/archive/2004/11/12/256783.aspx) and read that memory leak saga about regular expressions but "We've fixed that problem in Whidbey" caught my attention. They did? Yes, DynamicMethod does by making it so code can be emitted and executed from the managed heap - very cool. I had to know if XslCompiledTransform used this, so I reflected across Microsoft.*.dll and System.*.dll to see what uses DynamicMethod... Yes, XslCompiledTransform does. Nice - but I'm not sure it uses that exclusively. Given it actually spits out .dll files, I have to assume it Assembly.Loads and executes them... We avoided any potential leaks in a web app by holding the tranforms in the Application dictionary. This also made the whole thing faster since each transform was only compiled once.

By the way, I would encourage .NET devs out there to look in to getting certified (MCTS or MCPD). Don't be a wuss and shape-test your way through. (Shape-test refers to the process of getting test guides that so exactly mirror the real test that you can just memorize the shape of the correct answer to ace it. - I bet if given those kind of study guides written in Thai, I could pass the test. That's bull-khrap.)

Thursday, October 18, 2007 1:42:13 AM (US Mountain Standard Time, UTC-07:00)  #    Comments [0] -
.NET Internals | Certification
Archive
<October 2007>
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910
All Content © 2009, Hafthor Stefansson - Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way. - Sign In