This project is read-only.

Memory leaks

Feb 9, 2015 at 5:09 PM
I am using SharpShell to get a context menu using .Net 4.0 with lots of Icons & sun menus.
I noticed what seems to be memory leaks: In the TaskManager, I can see that explorer.exe uses more and more memory, "USER Objects" and "GDI Objects".

I have tried to simplify my context menu (e.g. no longer loading icons) only few items displayed, but I still see the same type of leaks (with a different level of magnitude).

Has someone faced the same type of issues / what would you recommend to avoid such leaks?
Mar 1, 2015 at 11:09 AM
Hey, I did not run into the same issue yet but some time ago I wrote a service that had same effect.

Do you use COM (RCW) Objects? When yes - do you release (null, Marshal, GC) them and stuff?
Do you use other IDisposable without using / Dispose() call?

Maybe some reference gets never NULL so it does net get picked up by the GC?
Or you never give the GC enough time to collect and dispose at all.

For me it helped when I wrapped every object and disposed it explicitely (then called GC).
Also it helps when you try not to cascade your objects.
COM1 = new COM1().getCOMObject().getCOMObject() -> Bad
COM1 = new COM1();
COM2 = COM1.getCOMObject();
COM3 = COM2.getCOMObject();

-> Then you can dispose every Object (Dispose/Release via Marshal), set to NULL and let the GC collect it.

Maybe it helps?