.Net Profiler API's in production environment

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
Posts: 1
Joined: Mon Aug 20, 2007 9:30 pm

.Net Profiler API's in production environment

Post by javiers » Mon Aug 20, 2007 9:43 pm


I've used the API in my code to detect memory leaks, and works great when the Profiler is used, but when is runing directly from the VS2005 the assert method always returns true.

Is it posible to use the Memory Profiler 3 APIs to be run in production? (activated by config).

I'm trying to show a MessageBox informing if exists a memory leak problem.

Here is the code:

Code: Select all

       Dim memoryCheck as Boolean = (config)

        If memoryCheck Then
            snapShot = SciTech.NetMemProfiler.MemProfiler.FullSnapShot()
        End If
(.........code to check here..........)
        If memoryCheck Then
            If Not SciTech.NetMemProfiler.MemAssertion.NoNewInstances(snapShot) Then
                MessageBox.Show("Memory Leak Detected")
            End If
        End If
When I run this using the profiler, the messagebox is shown, but when I run it directly from VS2005, MemAssertion.NoNewInstances always returns true. I also noticed that the IsProfiling property is set to false. Is it posible that the API do the memassertion when is runing using Debug->Start Debugging (from the VS2005 menu)?

Thanks in advance.

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Post by Andreas Suurkuusk » Tue Aug 21, 2007 5:36 pm

As you have noticed, the assertion methods always return true when the profiler is not active. When you select "Debug->Start Debugging" in Visual Studio, the program is not started by the profiler, and thus IsProfiling will return false and the assertion methods will always return true.

In order to debug a profiled program, you need to start it using the profiler (e.g. by using "Profiler->Start Profiling" in Visual Studio) and then attach the Visual Studio debugger using "Debug->Attach to Process".

We will look into this and will probably add a feature to make it easier to debug a profiled application, e.g. by adding a "Profiler->Start Profiling and Debugging" command.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 21 guests