I am using c# Shell32 library which I understand is a COM Object. Typically with COM objects I have to take care of the memory clean up after use. Was wondering how to cleanup at this point I set the object instance to null in the finally of the function. Is there a better way? Thanks
Asked
Active
Viewed 29 times
0
-
1You achieve nothing by setting local variables to null. Let the GC [do its work](https://stackoverflow.com/a/25135685/11683). – GSerg Jan 07 '22 at 17:33
-
@Mgtez there isnt a dispose method on the class itself, the only other way if I create a wrapper class and implement it on my own. But how to clean it up? – Arnold Jan 07 '22 at 18:16
-
Shell32 objects are very small and in-process, no need to babysit them. Use the [memory usage tool](https://learn.microsoft.com/en-us/visualstudio/profiling/profiling-feature-tour?view=vs-2022#analyze-memory-usage) in VS, ensure you see garbage collections happen and you won't have a problem. – Hans Passant Jan 07 '22 at 20:26