In my previous post, I classified the different memory resources available in the .NET CLR and I explained the role of the IDisposable interface as well as the use of the Finalize() method.
In this post, I am going to talk more about the implementation details of IDisposable and Finalize().
For reference, I have split this matter into two posts:
Posted by Joao Morais on April 29, 2012
(It took me more than a year to finish writing this article – a “hot topic” and I wanted it to be clear, simple and right. Also, I was busy and did not want to publish anything “unfinished”. As usual, your feedback and comments are more than welcome. Thank you in advance)
Recently (February 2011), I had to review some .NET code and came across of some wrong implementations of IDisposable.
After discussing with the developers, there were many reasons for what I found, ranging from:
- Not knowing the difference between a “CLR memory resource”, a “managed resource” and an “unmanaged resource”;
- Not understanding “how and when” resources are “released”;
- Not knowing when to override the “Finalize()” method and what should be released by a finalizer?
Posted by Joao Morais on April 26, 2012
All .NET applications at sometime will have to deal with an exception. It is just a matter of time. As application run longer in PRODUCTION phase than in development (unless it is a prototype ;)) the more information you can get out of the exception, the more likely you will be able to quickly pinpoint the root cause and resolve the issue.
I know, this might seem a little too basic, but there are still some misuses of Exception and misunderstanding about how to raise/re-raise exception without losing the original information. So here it is my contribution to help to improve the “good” use of Exception programming in .NET (samples are in C#, but the principles are valid for the .NET platform). (more…)
Posted by Joao Morais on January 13, 2012
Microsoft has just released a new performance analysis tool, called PerfView (download here).
It can help to isolate CPU- and memory-related performance issues. As I do a few performance analysis per month, this is a very good news – something new to try. (more…)
Posted by Joao Morais on January 4, 2012
Recently, I had to look at an issue in our code regarding “Connection request timed out”. Our Oracle connections are set to use the Pooling service offered by ODP.NET. Oracle documentation as the following description:
“The Max Pool Size attribute of the ConnectionString property sets the maximum number of connections for a connection pool. If a new connection is requested, but no connections are available and the limit for Max Pool Size has been reached, then the connection pooling service waits for the time defined by the Connection Timeout attribute. If the Connection Timeout time has been reached, and there are still no connections available in the pool, the connection pooling service raises an exception indicating that the connection pool request has timed-out.” [Ref-01, p3-6]
Posted by Joao Morais on September 2, 2011
I recently had to look at the memory consumption of a .NET process (running as a service). The process memory was growing up and we wanted to see how the memory was used (on a Windows 2003 SP2-32 bits server machine).
Using WinDbg, we created a dump of the process memory. Then I tried to look at it on my development machine (Windows XP SP2, 32 bits) and I got the error message “Failed to load data access DLL, 0x80004005“. The error was about the version of “mscordacwks.dll“.
Posted by Joao Morais on April 15, 2011
I started using WPF about a year ago. I liked the way the WPF team managed to split the behaviour of controls from their graphical rendering. This is very powerful and one of the area of ambiguity in the past where logic code ended up in the UI part of your application, making the maintenance more complex and breaking things a lot easier.
During that “learning journey of WPF”, I went through some “challenges” (or issues, depending on how you see the half-full/empty glass of water). This is my first blog to keep track of some of those “challenges” and shared them.
Recently, I had to present to the end user a “list” of choices to filter out items from another control. I used an enumerated type with the “Flags” attribute to define the possible distinct choices. (more…)
Posted by Joao Morais on March 30, 2011
This is a quick sample code that I used quite often on customer sites:
- To Check whether or not I am a local admin on my machine.
- To quickly list what Windows groups my user account is part of.
Posted by Joao Morais on February 15, 2011
Recently I was looking at technologies for “Excel Addins” and come across “Excel DNA” (used by some of my colleagues). It is a free framework with a very permissive open-source license.
My need was to be able to consume a WCF service (.NET 3.0) from some VBA code in Excel 2007. Excel-DNA helped to make the final solution very easily. I did a prototype (more…)
Posted by Joao Morais on January 28, 2011
Today, I went to 4 sessions.
First one was presented by Dino Esposito and about “Managed Extensibility Framework (MEF) in Action”. MEF is now part of .NET 4.0 framework
The primary role of MEF is to extend the application at runtime. As a framework, it is to improve productivity by providing the required features for extensibility and dicosvery. (more…)
Posted by Joao Morais on November 11, 2010