GDI Leak
Status: Beta
Brought to you by:
sjkirk
In file ShellItem.cs, method GetSystemImageListIndex calls Shell32.SHGetFileInfo but doesn't free the icon. To eliminate GDI object leaks (which prevent diplaying folder trees with more than a few thousand subfolders), add this line just before the return.
User32.DestroyIcon(info.hIcon); // GDI leak otherwise
Also, add
[DllImport("user32.dll")] public static extern bool DestroyIcon(IntPtr handle);
in class User32 in User32.cs
Another solution...from the same method GetSystemImageListIndex, you can remove the flag SHGFI.ICON from SHGetFileInfo to eliminate the GDI leak so you don't have to Destroy the icon. SHGFI.SYSICONINDEX is enough for getting the image from the image list.