ANTS Memory Profiler Latest version: 6.0
Knowledge Base
Problems with ANTS Memory Profiler 5 and multiple AppDomains
Category: Troubleshooting & error messages
Date: 21 Aug 2009
Product: ANTS Memory Profiler
There seems to be a generic issue with the above: the problem is with obtaining the right object references due to the different AppDomains used. The symptoms are a crash in the ClassLoader.
STACK_TEXT:
00d8ce58 79fccf05 bfb016a7 063bef90 00d8d1fc mscorwks!StackingAllocator::GetCheckpoint
00d8d068 79e92180 00d8d0c8 06d89210 0200005c mscorwks!ClassLoader::CreateTypeHandleForTypeDefThrowing+0xed
00d8d0b8 79e913aa 00d8d1fc 00d8d378 00d8d07c mscorwks!ClassLoader::CreateTypeHandleForTypeKey+0xba
00d8d1e8 79e914fa 00d8d258 00d8d378 00000000 mscorwks!ClassLoader::DoIncrementalLoad+0xa7
00d8d280 79e9161a 00d8d304 00d8d378 00000000 mscorwks!ClassLoader::LoadTypeHandleForTypeKey_Inner+0x12c
00d8d2f0 79e91243 00d8d330 00d8d378 00000000 mscorwks!ClassLoader::LoadTypeHandleForTypeKey_Body+0x1da
00d8d348 79e91fcb 00d8d39c 00d8d378 00000000 mscorwks!ClassLoader::LoadTypeHandleForTypeKey+0xae
00d8d3b4 79e9aa6b 00d8d434 06d89210 0200005c mscorwks!ClassLoader::LoadTypeDefThrowing+0x193
00d8d414 79f263aa 00d8d474 06d89210 0200005c mscorwks!ClassLoader::LoadTypeDefOrRefThrowing+0x1da
00d8d4a8 7a121395 06d89210 0200005c 00d8d4d0 mscorwks!ClassLoader::LoadTypeDefOrRefNoThrow+0x86
00d8d4d4 63e76a57 00000000 0200005c 00d8d50c mscorwks!ProfToEEInterfaceImpl::GetClassFromToken+0x57
00d8d4e8 10005e97 00161c78 06d89210 0200005c mscordbc!CorProfInfo::GetClassFromToken+0x2c
00d8d90c 100067ba 06d89210 00161c78 b956917f RedGate_Memory_Core!CNetClass::ClassIDFromDef+0x87 [d:\work\antsmemoryprofiler\5.2.0\core\netclass.h @ 446]
We've logged a bug for this but we have a workaround that is good (for profiling purposes at least).
Parametize your main method with:
[System.LoaderOptimization(LoaderOptimization.MultiDomain)]
or
[System.LoaderOptimization(LoaderOptimization.MultiDomainHost)]
If you don't have a main method, for example: if you have a WPF project, take a look at this article which shows you how to do it:
http://www.matthidinger.com/archive/2008/10/12/increase-addin-performance-with-maf-and-wpf-using-loaderoptimization.aspx
(Thanks to Matt Hidinger- that's the second time you've helped me :)

Understanding memory problems