MemAssertion.NoInstances(Type[], bool)

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

Moderator: SciTech Software

MemAssertion.NoInstances(Type[], bool)

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

Why doesn't this code assert?

class Parent { }
class Child : Parent { }

class Program
{
static void Main(string[] args)
{
Type[] types = new Type[] { typeof(Parent) };
MemProfiler.FastSnapShot();

MemAssertion.NoInstances(types, true);
Child child = new Child();
MemAssertion.NoInstances(types, true); // fails to assert
}
}
scot.prichard@med.ge.com
 
Posts: 3
Joined: Wed Feb 01, 2006 10:43 pm

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

In a debug build the assertion should probably fail, but since the child variable is not used after the assertion, it is possible that the Child instance becomes collected before the assertion. In a release build the scopes of variables are smaller, and the assertion will never fail.

However, the reason that the assertion doesn't fail is that the includeSubclasses argument was ignored by the NoInstances methods that accept a Type[] array. This 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: 962
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 1 guest

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