Urgent -There is already a profiler attached to this process

Memory profiling for .NET developers

Moderators: Luke Jefferson, StephenC, AndrewH, melvyn.harbour, james.billings, Laura Morley, dene.boulton

Urgent -There is already a profiler attached to this process

Postby gsuttie » Mon Jun 13, 2011 1:54 pm

Folks we have an urgent problem with trying to attach Ants profiler to .net 4 process - we are getting the following error message.

There is already a profiler attached to this process.

Exception from HRESULT 0x8013136A

Could someone please help asap.

I am a friend of redgate and using your tool on site and would really appreciate some quick advice.

Many thanks
Gregor
gsuttie
 
Posts: 44
Joined: Wed Nov 30, 2005 9:09 pm
Location: Glasgow, Scotland

Postby AndrewH » Mon Jun 13, 2011 2:26 pm

.NET only allows one profiler to be attached to any given process, so this error occurs whenever anything else using the profiling API is already attached to the target process. Unfortunately, the error reported to ANTS is exactly as displayed on screen, so it has no way of knowing what the other profiler is.

It's possible that a crashed UI session would leave behind the ANTS profiler core in the target process. Unfortunately, there's no way to unload the core at this point other than by restarting the process.

Hm, it occurs to me that we haven't tried the case where the profiler environment variables are set but the profiler doesn't start. I think that the core should unload itself and allow a future attach, but I haven't actually tried it.

If it's not ANTS, tracking down the culprit is going to be more difficult. You should be able to see the profiler DLL that's loaded using SysInternals process explorer (ANTS memory profiler will be RedGate.Memory.Core.dll). You can also look at the environment variables to find third-party profilers: specifically, the COR_PROFILER environment variable, which if it's set will be set to the GUID of a COM+ component, which can be looked up in the registry to find out what's being loaded (then you'll need to configure whichever tool it is to stop loading on the target process). If the profiler attached itself via the .NET API, these variables won't be set, so the only way to find out what the profiler is is to spot the actual DLL that's being loaded.

There is at least one third-party profiler that works by loading itself in via this mechanism to every running process on the system to implement its own attach mechanism (this effectively disables any other profiler from running on the system). I *think* IntelliTrace also loads a profiler into anything it's being run on, so that will need to be turned off to make the profiler work.
Andrew Hunter
Software Developer
Red Gate Software Ltd.
AndrewH
 
Posts: 134
Joined: Thu Aug 17, 2006 3:44 pm


Return to ANTS Memory Profiler 7

Who is online

Users browsing this forum: No registered users and 0 guests