C# icorprofilercallback4::SurvivingReferences

86 views Asked by At

I would like to be able to find all the surviving references of some kind of object in any application without having to use an external memory profiler.

My basic idea is that, I just want to be able to list all the alived UserControls inside my app with the name and the object size, this will allow me to spot all the unused controls witch are not really dead :)

After some google researchs I found something that should serve my interests.

icorprofilercallback4::SurvivingReferences

Looks like this is pure C++ and I was not able to find any king of sample.

Did someone already try to do that? I am on the right direction to look for a solution?

Thx for you interest in my question.

1

There are 1 answers

5
Ed Pavlov On

This interface is a part of Microsoft Profiling API. All .NET memory profilers (which you do not want to use) use this API to collect data. For your case you need to obtain all live objects ('survived' is just a subset of them). To obtain object type names you should bind obtained data with assembly metadata and so on.

So, you are on the right way, but this way is very, very, very long. Using one of existent tool is drastically shorter, I would recommend you this way.