.NET Oddities #3

OK, so I’ll admit this is a bit cheeky: this entry should almost certainly be .NET Oddities #2a because it’s so closely related to #2, but there. You may have noticed, and in fact I already knew this, that OutOfMemoryException (like StackOverflowException) has a null value for its StackTrace property. Again, this can be a total pain in the butt, however fortunately for me it was Dan that did the hard work and tracked it down this morning (for which I’m exceedingly grateful). Of course, things are never quite that simple, and it turned out that the bug behind all of this was actually elsewhere in the code, so I didn’t totally escape having to do some work.

I should also qualify all of this by saying that it isn’t just .NET that behaves in this way. The most recent version of Java that I used in anger (1.4.2) also behaves like this: no stack trace from OutOfMemoryError. Now admittedly I want to have my cake and eat it, but how useful would it be if the JVM and CLR provided this information, even if it was only a partial stack trace from the point where the exception/error occurred back up through a few stack frames? I think that would be very cool indeed, although somehow the VMs in question would need to reserve enough memory to pull off this little trick, and it could well be a complete pain to implement, and, well you get the picture… but in an ideal world, how cool would it be?

Anyway, “You may say that I’m a dreamer…” 😉

That’s all for now. The new version of DTS Package Compare (formerly DTS Compare) is coming along a treat so I’m going to get back to it. Watch this space.