MemAssertion.NoNewInstances(), NoNewInstancesExcept(Type)

Use this forum to discuss and/or suggest future improvements of .NET Memory Profiler and to report bugs.

Moderator: SciTech Software

MemAssertion.NoNewInstances(), NoNewInstancesExcept(Type)

Postby scot.prichard@med.ge.com » Wed Mar 15, 2006 10:25 pm

Why does this code Assert?

class Test { }

class Program
{
static void Main(string[] args)
{
MemProfiler.FullSnapShot();
MemProfiler.FullSnapShot();
MemAssertion.NoNewInstances();
MemProfiler.FullSnapShot();
using (MemAssertion.BeginAssertions())
{
MemAssertion.NoNewInstances();
}

Test test = new Test();
MemAssertion.NoNewInstancesExcept(typeof(Test));
}
}
scot.prichard@med.ge.com
 
Posts: 3
Joined: Wed Feb 01, 2006 10:43 pm

Postby Andreas Suurkuusk » Thu Mar 16, 2006 1:11 pm

Using MemAssertion.NoNewInstances and MemAssertion.NoNewInstancesExcept require that you perform the assertions in an "assertions session", otherwise it is very likely that memory leaks will be falsely detected. So in your case, the first and the third assertion will fail, since short-lived instances will be created during the assertion itself. However, the second assertion should not fail.

It appears that assertions didn't work when using a MemProfiler.FullSnapshot as comparison snapshot. This was a bug in the profiler which has now been fixed and an updated version of the profiler has been released. You can download this version (v2.6.82) from http://memprofiler.com/download.aspx.
Best regards,

Andreas Suurkuusk
SciTech Software AB
Andreas Suurkuusk
 
Posts: 976
Joined: Wed Mar 02, 2005 7:53 pm
Location: Sweden


Return to Future Improvements

Who is online

Users browsing this forum: No registered users and 3 guests

SciTech Software logo

© Copyright 2001-2016. SciTech Software AB
All rights reserved.


SciTech Software AB
Kartvägen 21
SE-175 46 Järfälla
Sweden


E-mail: mail@scitech.se

Telephone: +46-706868081

cron