Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Liveness extended with enabled timing
Boris Letocha
#1 Posted : Tuesday, January 31, 2012 10:36:18 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/31/2012(UTC)
Posts: 3

This test should pass, but it is not in 1.37b with default settings.

using System;
using NUnit.Framework;

namespace ClassLibrary1
{
[TestFixture]
public class Class1
{
[Test]
public void Test()
{
var weak = new WeakReference(new object());
GC.Collect();
GC.WaitForPendingFinalizers();
Assert.False(weak.IsAlive);
}
}
}
Remco
#2 Posted : Tuesday, January 31, 2012 11:34:23 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi Boris,

Thanks for reporting this. I couldn't get this test to fail when running it locally, so I'm wondering if I might be able to ask some more questions about this issue..

- Is the failure pattern consistent? (i.e. run the test 5-10 times manually or while your system is under load to see if it fails every time)
- What version of the .NET framework are you testing in?
- Does the 'Analyse line execution times' setting have any effect on the result of this test?

Thanks!

Remco
Boris Letocha
#3 Posted : Tuesday, January 31, 2012 11:49:16 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/31/2012(UTC)
Posts: 3

Yes it is consistent. just create c# class library project in VS add NUnit through Nuget, paste this code, enable NCrunch.
I have installed .Net 4.5 CTP, but this runs in VS2010 with selected .Net 4.0
Yes switching off 'Analyse line execution times' is workaround for this problem.
Remco
#4 Posted : Wednesday, February 1, 2012 12:04:53 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Can you give me any information about the system you're running test on? Is it x64/x86? Multi-core? Hyperthreaded?
Boris Letocha
#5 Posted : Wednesday, February 1, 2012 7:59:33 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/31/2012(UTC)
Posts: 3

It is Multi-core, both hyperthreaded (Work PC) and without hyperthread (Home PC).
CPU architecture in NCrunch settings must be AutoDetect or x86. On x64 it works.
Class Library itself is just Any CPU.
I also submitted bug report if it helps you.
Remco
#6 Posted : Wednesday, February 1, 2012 8:49:48 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Thanks - I'll see what I can do :)
Remco
#7 Posted : Wednesday, July 4, 2012 10:28:28 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
It's taken a while, but I've finally managed to get to the bottom of this issue after unintentionally reproducing it.

It seems that the .NET 4.5 installer introduces a subtle change in the garbage collection behaviour of the CLR, which affects not only .NET 4.5 but also other installed versions of the framework before it.

The change appears to suppress garbage collection of objects created inside of a try block, even when the garbage collector is being specifically invoked with a GC.Collect(). The objects are instead collected after the try/finally block has been fully executed.

The reasoning behind this isn't clear to me, as objects that are created and go out of scope inside a try block shouldn't really have a reason to exist. I would speculate that this change was introduced as a part of another change to generally improve reliability or make space for more features in the CLR.

Anyway, the change causes some problems for NCrunch when executing tests that are similar to the one you've described above, as NCrunch uses try/finally blocks as part of its performance analysis instrumentation. As described above, to work around the issue, just disable the 'Analyse line execution times' project-level NCrunch configuration setting for the project making use of the WeakReference.
1 user thanked Remco for this useful post.
lee_oades on 11/2/2012(UTC)
lee_oades
#8 Posted : Friday, November 2, 2012 4:36:56 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/2/2012(UTC)
Posts: 1
Location: United Kingdom

Thanks: 1 times
Fascinating. Just ran into this issue and have switched off the setting as advised. Thanks! And well done getting to the bottom of it.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.057 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download