| Do try...catch blocks hurt runtime performance? | Posted on Tuesday, February 19, 2008 at 6:23 AM | Recently, a friend mentioned that someone had told him that writing a try...catch block in C# (or substitute some other .Net language here) resulted in a "huge penalty" in terms of performance compared to if you had not written it. That is, merely writing such a block actually hurt program performance, even if an exception was never thrown. He didn't believe this was true, and rightly so - it's completely wrong. This post is a tidied up version of my explanation.
Inside a .Net Assembly
A .Net assembly, if we ignore various headers, consists of three things:
- Bytecode: a sequence of low-level instructions that specify the body of a method
- Metadata: a set of tables, a little bit like a database, describing higher level constructs such as classes, methods, signatures and so forth
- Heaps: places where string constants and other such things are stored
Read More |
|
Subscribe
RSS Feed
More Tags
.NET C C# C# 3.0 C++ Embedded engineering service eveh3d firmware Hardware Linux Made-In-China offshore Operating System Outsource Perl product development Programming R&D Software
Help
Check out the Blog FAQ.
|