0

I was searching for .NET memory leak detection tools and .NET profilers - on internet there is plenty of them, however - they are all commercial tools. I would like to check if there is any open-source alternative, what is their development status (what is working and what is not working), and if it's possible - if someone could pinpoint me to which API's are used to "hook" .NET garbage collector.

Also I've understood that reference analysis is non-trivial - if GC does not collect memory - then it means that someone references that data - so that in a turn requires some sort of reference backtracking - also interesting what API's and techniques exists to analyze references.

I would prefer that code would be low level - preferably C / C++ - I suspect that it has something to do with C++ / COM undocumented API's. But if there is also C# interfaces to perform memory analysis - I could take them as well.

So if it's possible:

  • can you post here links to open source code projects / codes which hooks .NET memory management.
  • can you post links to API documentation which relates to hooking memory management.
TarmoPikaro
  • 4,723
  • 2
  • 50
  • 62
  • VS 2015 has built-in profiler. I don't know, is it included in the Community Edition or not, but why don't try to find it out? – Dennis Apr 10 '16 at 10:37
  • I'm interested in technology underneath - so want to create memory analyzer / profiler similar to Visual Studio's. I have already implemented native memory leak detection tool, want to analyze bit deeper what it takes to expand support to managed side. – TarmoPikaro Apr 10 '16 at 10:42
  • If you are really interested in the tech itself, make sure you visit both CoreCLR and CoreFX repos Microsoft published at GitHub. That shows you all the implementation details and you should be able to find out what you can hook. – Lex Li Apr 10 '16 at 12:49
  • https://github.com/dotnet/coreclr/blob/master/src/inc/corprof.idl – Hans Passant Apr 10 '16 at 14:37
  • Any sample project which uses those API interfaces ? You can add this as an answer, because it's partially answer to my question. – TarmoPikaro Apr 11 '16 at 05:48

1 Answers1

0

Here is what I've briefly analyzed so far - from my own older question - Resolve managed and native stack trace - which API to use?

I've tracked down and went by SOS/Strike link, where you can locate following information:

From this git repository: https://github.com/dotnet/coreclr/blob/master/src/ToolBox/SOS/Strike/sosdocs.txt

You can find brief description about what kind of commands windbg supports (like for instance DumpHeap), and correspondingly their implementation in:

https://github.com/dotnet/coreclr/blob/master/src/ToolBox/SOS/Strike/strike.cpp

But this is more of less windbg extension - never managed to compile it due to missing project, and also it looks like analysis tool after problem appeared - I would prefer to be actively hooked into memory allocation chain.

I guess correspondent code to sos / strike does not exists ?

Community
  • 1
  • 1
TarmoPikaro
  • 4,723
  • 2
  • 50
  • 62