Reputation: 49
How come when my WPF application leaks unmanaged memory and I close it immediately, nothing special happens. But when it leaks unmanaged memory and I leave it sitting for 1 hour (not touching the computer at all) and then I close it, it will crash with an out of memory exception on the Form.Close()
call? (while debugging)
It's not because leaked memory has accumulated. It happens even with a little bit of leaked memory.
I want to speed up the process causing this, so that I don't have to sit around for hours while debugging a memory leak trying if it still happens.
Example causing a memory leak:
[DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr LoadImage(
IntPtr hInstance,
string name,
uint type,
int width,
int height,
uint load);
IntPtr hIcon = LoadImage(
IntPtr.Zero,
iconPath,
IMAGE_ICON,
32,
32,
LR_LOADFROMFILE | LR_DEFAULTSIZE);
I'm talking .NET 6 here, but I suspect it applies to other versions too.
Upvotes: 0
Views: 177