How to detect and avoid memory and resources leaks in .NET applications

MSDN features an article covering reasons why and how managed applications can suffer from memory leaks, how you can find them and get rid of them:

Despite what a lot of people believe, it’s easy to introduce memory and resources leaks in .NET applications. The Garbage Collector, or GC for close friends, is not a magician who would completely relieve you from taking care of your memory and resources consumption.

I’ll explain in this article why memory leaks exist in .NET and how to avoid them. Don’t worry, I won’t focus here on the inner workings of the garbage collector and other advanced characteristics of memory and resources management in .NET.

It’s important to understand leaks and how to avoid them, especially since they are not the kind of things that is easy to detect automatically. Unit tests won’t help here. And when your application crashes in production, you’ll be in a rush looking for solutions. So, relax and take the time to learn more about this subject before it’s too late.

How to detect and avoid memory and resources leaks in .NET applications weiterlesen

Tooltips for indivual cells of a DataGrid

Just recently,  I have been faced with the question on how to add cell dependent tooltips to individual cells of a DataGrid in Silverlight. If you generate the columns by yourself, the task is straight forward by using the appropriate data template for the cell. Something like this:

<Data:DataGrid>
   <Data:DataGrid.Columns>
      <Data:DataGridTemplateColumn>
         <Data:DataGridTemplateColumn.CellTemplate>
            <DataTemplate>
               <TextBlock  Text="{Binding ColumnProperty}"
                    ToolTipService.ToolTip="{Binding ColumnProperty}"/>
            </DataTemplate>
         </Data:DataGridTemplateColumn.CellTemplate>
      </Data:DataGridTemplateColumn>
   </Data:DataGrid.Columns>
</Data:DataGrid>

However, if you let the columns be autogenerated by the grid, things are not so straight forward anymore. Tooltips for indivual cells of a DataGrid weiterlesen