microsoft / CLRInstrumentationEngine

The CLR Instrumentation Engine is a cooperation profiler that allows running multiple profiling extensions in the same process.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory leaks on process shutdown

delmyers opened this issue · comments

Our ref counting is indicating memory leaks on process shut down.

It looks like this is probably due to a circular reference between App Domains and the Module Infos contained therein. That circular reference is meant to be broken when we get a module unload callback, but that callback is not guaranteed on process shut down. We will likely also leak App Domain references on shut down because I don't think we are guaranteed to get a callback for that either. Essentially, I think all bets are off on callbacks during process exit.

We might need to have better memory leak detection. It probably wouldn't hurt to be a little better about circular references anyway. For example, there is no need to hold a ref-counted reference to the App Domain from the Module Info, since the App Domain should keep it alive.

#142 might make that difficult to write a test with a real runtime if anything is released in the profiler's is deconstructor.