Skip to main content

Posts

Showing posts with the label c#.Net

Memory Leak Analysis for .Net application

Memory leaks in .Net applications are always proven to be the nightmare for developers. Many times we get “OutOfMemoryException”, which is nothing but due to memory leak only. There are many reasons, which lead to memory leak situation. For example, sometimes we forget to release unmanaged resources, dispose heavy objects (i.e., drawing objects), even holding reference of managed objects, longer than necessary can also lead to memory leaks. So, if the application is small, one can analyze the code and figure it out, which object is causing memory leak. But when it comes to a large application, it is not at all possible to figure out manually. In that case, we need some tool, which can help us to figure out the area or object, which is causing memory leak. So, today I surf internet and came up with a tool called .Net Memory Profiler, which can do analysis for us and give us the statistics of all the instances. Ok, instead of getting more into theory, let’s jump quickly to the

Reducing flicker, blinking in DataGridView

One of my project requirement was to create a Output Window similar to Visual Studio. For that I used a DataGridView. But when I start my application , I found that there is lot of blinking, flicker, pulling... After badly hitting my head with google, I found a very easy way. We just need to create a extension method to DataGridView and it's all done: public static void DoubleBuffered(this DataGridView dgv, bool setting) {     Type dgvType = dgv.GetType();     PropertyInfo pi = dgvType.GetProperty("DoubleBuffered",           BindingFlags.Instance | BindingFlags.NonPublic);     pi.SetValue(dgv, setting, null); } CodeProject