Skip to content

Memory leak when using IThumbnailProvider.GetThumbnail() #421

@tigrouind

Description

@tigrouind

The bitmap handle acquired after calling GetThumbnail() is never released.

SharpShell should provide a way to release it (eg: by returning a IDisposable instance). Otherwise after many calls memory leak occurs (Windows is likely to get out of handle and GDI+ errors will arise).

Here is my workaround :

[DllImport("gdi32.dll", EntryPoint = "DeleteObject")]
public static extern bool DeleteObject(IntPtr hObject);

if (thumbnail.GetThumbnail(..., out IntPtr bitmapHandle, out ...) == 0)
{
	try
	{	
		...
	}
	finally
	{
		DeleteObject(bitmapHandle);
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions