<p>I am trying to find a way to determine at run-time how much memory a given class is using in .NET.  Using <code>Marshal.SizeOf()</code> is out, as it only works on value types. Is there a way to check exactly how much memory a class uses?</p>

[{'answer_id': 51554, 'author': 'Jarod Elliott', 'author_id': 1061, 'author_profile': 'https://Stackoverflow.com/users/1061', 'pm_score': 4, 'selected': True, 'text': '<p>I\'ve only recently started looking into this type of thing, but i have found that memory profilers can give quite detailed information regarding instances of objects within your application.</p>\n\n<p>Here are a couple that are worth trying:</p>\n\n<ul>\n<li><a href="http://www.red-gate.com/Products/ants_profiler/index.htm" rel="noreferrer">ANTS Profiler</a></li>\n<li><a href="http://memprofiler.com/" rel="noreferrer">.NET Memory Profiler</a></li>\n</ul>\n'}, {'answer_id': 51895, 'author': 'McKenzieG1', 'author_id': 3776, 'author_profile': 'https://Stackoverflow.com/users/3776', 'pm_score': 1, 'selected': False, 'text': '<p>I agree that a memory profiler is the easiest way to get the information you are looking for. In addition to the two previously mentioned, I recommend JetBrains <a href="http://www.jetbrains.com/profiler/index.html" rel="nofollow noreferrer">dotTrace</a>, which is both a performance profiler and a memory profiler.</p>\n\n<p>If you want to do it yourself, and are willing to get pretty deep into the guts of the CLR, you can use the <a href="http://msdn.microsoft.com/en-us/library/ms404386.aspx" rel="nofollow noreferrer">.NET Profiling API</a>, which is an unmanaged API that (as Microsoft says): "enables a profiler to monitor a program\'s execution by the common language runtime (CLR)." It\'s not exactly intended for casual use, but it does have an enormous amount of functionality.</p>\n'}, {'answer_id': 52082, 'author': 'Jakub Šturc', 'author_id': 2361, 'author_profile': 'https://Stackoverflow.com/users/2361', 'pm_score': 1, 'selected': False, 'text': '<p>just link to related SO question:</p>\n\n<ul>\n<li><a href="https://stackoverflow.com/questions/26570/sizeof-equivalent-for-reference-types">sizeof() equivalent for reference types?</a></li>\n</ul>\n'}]
['https://Stackoverflow.com/questions/51540', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2470/']