<p>As far as I can tell, this is isn't possible, so I'm really just hoping for a left field undocumented allocation hook function.<br>
I want a way to track allocations like in <a href="http://msdn.microsoft.com/en-us/library/cy8c7wz5.aspx" rel="nofollow noreferrer">_CrtSetAllocHook</a>, but for <code>C#/.NET</code>.<br>
The only visibility to the garbage collector/allocation appears to be <a href="http://msdn.microsoft.com/en-us/library/system.gc.collectioncount(VS.80).aspx" rel="nofollow noreferrer">GC.CollectionCount</a>.<br>
Anyone have any other .NET memory mojo?</p>

[{'answer_id': 50419, 'author': 'McKenzieG1', 'author_id': 3776, 'author_profile': 'https://Stackoverflow.com/users/3776', 'pm_score': 4, 'selected': True, 'text': '<p>The CLR has a \'profiling API\' that hooks into pretty much everything - it is what the commercial .NET memory profiling products use, I believe. Here is an MSDN link to the top level of the documentation: <a href="http://msdn.microsoft.com/en-us/library/bb384547.aspx" rel="noreferrer">.NET Framework General Reference: About the Profiling API</a></p>\n\n<p>See this MSDN magazine article for an introduction to the memory piece: <a href="http://msdn.microsoft.com/en-us/magazine/cc188781.aspx" rel="noreferrer">Inspect and Optimize Your Program\'s Memory Usage with the .NET Profiler API</a></p>\n'}, {'answer_id': 50600, 'author': 'Jonathan Allen', 'author_id': 5274, 'author_profile': 'https://Stackoverflow.com/users/5274', 'pm_score': 1, 'selected': False, 'text': "<p>I would just use Red Gate's ANTS Profiler. It will tell you a lot about what's going on in memory without you having to learn the profiling API yourself.</p>\n"}]
['https://Stackoverflow.com/questions/50391', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2642/']