I have came across with a GDI leaking problem in our project so I started to search for possible issues. I have found a place where the implementor created new instances of icons with LoadIcon and I do know that we have to delete the resource with DestroyIcon when closing the element which embedded it. What I don't know is that if the CImageList automatically calls this on the added elements or not? I did not find exact answers to this to date.

Thank you in advance.

有帮助吗?

解决方案

CImageList will release all the elements when it is released. Based on msdn, If the image list was created with the new operator, you must destroy the CImageList object when you are done with it, which means in the descontructor of CImageList, it release all its elements.

You can try to use DebugDiag to debug memory/GDI leak issues, it's better than just looking into the code to identify a leak.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top