<p>What resources have to be manually cleaned up in <em>C#</em> and what are the consequences of not doing so?</p>

<p>For example, say I have the following code:</p>

<pre><code>myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
// Use Brush
</code></pre>

<p>If I don't clean up the brush using the dispose method, I'm assuming the garbage collector frees the memory used at program termination? Is this correct?</p>

<p>What other resources do I need to manually clean up?</p>

Handles to internal windows data structures.
Database connections.
File handles.
Network connections.
COM/OLE references.
The list goes on.
It's important to call
```
Dispose
```
or even better yet, use the
```
using
```
pattern.
```
```
using (SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black))
{
    // use myBrush
}
```
```
If you don't dispose something, it'll be cleaned up when the garbage collector notices that there are no more references to it, which may be after some time.
In the case of
```
System.Drawing.Brush
```
, Windows will keep internal windows structures for the brush loaded in memory until all programs release their handle.