8/30/2004

Circular References, Memory Leaks, and other Baddies

In a garbage collected environment such as .NET, it is possible to unwittingly leave objects in a state where the garbage man will be "on vacation". One way to check on this kind of stuff is with profiling products such as the Scitech .NET Memory Profiler: http://www.scitech.se/memprofiler/

Ian Griffiths has a well - written, concise piece on this subject here: http://www.interact-sw.co.uk/iangblog/2004/07/07/circulareventrefs

One of the issues we found with this is when you have a lot of controls on a UserControl or form and you unwind it, thinking you have gotten rid of everything.

Except, you may have not done so - event handler delegate calls may still hold a reference to their target. We found this to be especially noticeable on controls derived from RichTextBox - a control with a lot of Interop going on under the hood and notoriously "Buggy" to boot.

The problem is solved with a neat little method we call in the Dispose Block , "UnregisterChildControls":

private void UnRegisterChildControl(Control ctrl)
{
if (ctrl is CustomCheckBox)
{ CustomCheckBox cb = (CustomCheckBox)ctrl;
cb.CheckedChanged -= new EventHandler(cb_CheckedChanged);
}

else if (ctrl is CustomDateComboBox)
{
CustomDateComboBox cmb = (CustomDateComboBox)ctrl;
cmb.DateSelected -= new DateSelectedHandler(cmb_DateSelected);
}
}

-- By "cleaning up our room" in this manner, we've seen those scary looking memory consumption profiles flatten out very nicely. :-)

8/29/2004

SQLite ADO.NET Provider and Compact Framework

Well, I spent a fruitless afternoon fiddling with SQLite 3.0.4, 3.0.5 and the Finisar SQLite ADO.NET provider. The provider works great for SQLite 3.0.X but there are serious issues with getting it to work ON the Compact Framework due to the marshaling deficiencies with C-style DLLs in CF.
Bottom line is, even though the provider has a .NETCF solution and test app, they'll compile fine - but they will always throw a System.MissingMethodException on the sqlite_open call.

This, after downloading the C source and recompiling my own SQLite3.dll library, to no avail!

Finally, a look at the Sqlite WinCE site shows the proof: "SQLite 3XXX has serious issues!"

Yeah, so does SQLite 2.8 too, if you want a 100% CF - based DBMS solution.
Disappointed,
--Pete

8/28/2004

Eh! SP2

Geez. They are making it into some sort of opening nite gala or something.

8/22/2004

An interesting C# managed-code wrapper for BITS (Background Intelligent Transfer) Eddie Tse: BITS C# Wrapper