RedGate.MemoryProfiler.Snapshot.TakeSnapshot() returns false

Memory profiling for .NET developers

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

RedGate.MemoryProfiler.Snapshot.TakeSnapshot() returns false

Postby abhijeet2083 » Thu Nov 03, 2011 10:44 pm

I am trying to get a snap shot from a very simple winform app when the profiler is running.
But RedGate.MemoryProfiler.Snapshot.TakeSnapshot("asd") always return false without any delay.

Any help appreciated.
Abhijeet
abhijeet2083
 
Posts: 2
Joined: Thu Nov 03, 2011 10:38 pm

Postby Brian Donahue » Mon Nov 07, 2011 12:55 pm

AFAIK this method should throw an exception if there is a problem and the return codes for this method are undocumented but just to clear up any potential misunderstanding:
  • Is ANTS Memory Profiler running at the same time as the application for which you've incorporated the snapshot API?
  • If so, does ANTS Memory Profiler inform you that it is taking the snapshot "asd" in its' UI?
  • If so, are any exceptions occurring in the Memory Profiler UI at the time the snapshot was invoked?
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

RedGate.MemoryProfiler.Snapshot.TakeSnapshot() returns false

Postby abhijeet2083 » Mon Nov 07, 2011 8:33 pm

Thanks for the reply.
Firstly answering your questions,
- Yes, the profiler & the app invoking API are running at the same time.
- After the API invoke, there is absolutely no change on the profiler UI.

Here is something I should have mentioned in my first post.

- I got a COM unregistered exception when I tried for the first time.
- That was when I registered the assembly RedGate.Memory.Core.dll from its location inside Program Files.
- And its after this register is the behavior mentioned in the first post.
abhijeet2083
 
Posts: 2
Joined: Thu Nov 03, 2011 10:38 pm

Postby Brian Donahue » Tue Nov 08, 2011 11:31 am

Well, according to the source code, TakeSnapshot returns false if
  • Profiler is not connected to the process
  • The memory profiler control can't be referenced (problem with RedGate.Memory.Core.dll)
  • Profiler busy detaching with the process (or a COM exception occurs)


So I guess I would check the first thing by trying to take a snapshot in the UI. Mem profiler has probably crashed the process or it's exited on its' own. According to your last update you registered RedGate.Memory.Core.dll.
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

Postby jrg » Mon Nov 21, 2011 6:27 pm

Just a thought - the snapshot API requires the profiled process to be started by the profiler - it's not enough for them to run at the same time.

    Start ANTS Memory Profiler.
    Set up ANTS Memory Profiler to profile your application in the normal way.
    When you click [startprofilingbutton] your application starts.
    Snapshots are taken automatically at the trigger points you defined in your code.

I got a COM unregistered exception when I tried for the first time.

That's odd, because the memory profiler's installer should have registered the COM object. Were there any problems running the installer?
return codes for this method are undocumented

There aren't any return codes as such, it either works (returns true), or fails (returns false), or throws an exception when the snapshot rate limiting is exceeded (5 in 30 seconds).
jrg
 
Posts: 13
Joined: Fri Jul 02, 2010 3:13 pm


Return to ANTS Memory Profiler 7

Who is online

Users browsing this forum: No registered users and 0 guests