VS 2008 Debugger going crazy?
-
Look at the simple code below
using System;
namespace Pattern
{
class Program
{
static void Main(string[] args)
{
Singleton s1, s2;s1 = Singleton.getSingletonInstance(); s1.instanceCount = 100; s2 = Singleton.getSingletonInstance(); } } sealed class Singleton { private static Singleton \_s = null; public int instanceCount; private Singleton() { //do nothing } public static Singleton getSingletonInstance() { if (\_s == null) { \_s = new Singleton(); } return \_s; } }
}
Put the breakpoint on line
if (_s == null)
and then observe the behavior when we do something likes2 = Singleton.getSingletonInstance();
When the breakpoint will hit, try watching the value of _s. The watch window will pop endlessly all over the screen when you click on the following + sign next to the static members icon. Screenshot : http://bp1.blogger.com/_J8sDhLDCDXA/SHv7z5Sx0RI/AAAAAAAAAIA/8xubz88GBJM/s1600-h/debugger.JPG Any clue why? -
Look at the simple code below
using System;
namespace Pattern
{
class Program
{
static void Main(string[] args)
{
Singleton s1, s2;s1 = Singleton.getSingletonInstance(); s1.instanceCount = 100; s2 = Singleton.getSingletonInstance(); } } sealed class Singleton { private static Singleton \_s = null; public int instanceCount; private Singleton() { //do nothing } public static Singleton getSingletonInstance() { if (\_s == null) { \_s = new Singleton(); } return \_s; } }
}
Put the breakpoint on line
if (_s == null)
and then observe the behavior when we do something likes2 = Singleton.getSingletonInstance();
When the breakpoint will hit, try watching the value of _s. The watch window will pop endlessly all over the screen when you click on the following + sign next to the static members icon. Screenshot : http://bp1.blogger.com/_J8sDhLDCDXA/SHv7z5Sx0RI/AAAAAAAAAIA/8xubz88GBJM/s1600-h/debugger.JPG Any clue why? -
Look at the simple code below
using System;
namespace Pattern
{
class Program
{
static void Main(string[] args)
{
Singleton s1, s2;s1 = Singleton.getSingletonInstance(); s1.instanceCount = 100; s2 = Singleton.getSingletonInstance(); } } sealed class Singleton { private static Singleton \_s = null; public int instanceCount; private Singleton() { //do nothing } public static Singleton getSingletonInstance() { if (\_s == null) { \_s = new Singleton(); } return \_s; } }
}
Put the breakpoint on line
if (_s == null)
and then observe the behavior when we do something likes2 = Singleton.getSingletonInstance();
When the breakpoint will hit, try watching the value of _s. The watch window will pop endlessly all over the screen when you click on the following + sign next to the static members icon. Screenshot : http://bp1.blogger.com/_J8sDhLDCDXA/SHv7z5Sx0RI/AAAAAAAAAIA/8xubz88GBJM/s1600-h/debugger.JPG Any clue why? -
Two things The code sample in this explanation [i.e.
public class X
] is not showing the same behavior. Don’t think it is because of the singleton. In fact, same behavior is visible in other scenarios. Accepted, it is doing some sort of circular referencing. Question is why and where? Anyways, the article on singleton is very good. -
Two things The code sample in this explanation [i.e.
public class X
] is not showing the same behavior. Don’t think it is because of the singleton. In fact, same behavior is visible in other scenarios. Accepted, it is doing some sort of circular referencing. Question is why and where? Anyways, the article on singleton is very good.abhigad wrote:
not showing the same behavior
Seemed to for me.
abhigad wrote:
where?
_s refers to an instance of the class, which contains _s. At any rate, this is not the proper forum for this.
-
Look at the simple code below
using System;
namespace Pattern
{
class Program
{
static void Main(string[] args)
{
Singleton s1, s2;s1 = Singleton.getSingletonInstance(); s1.instanceCount = 100; s2 = Singleton.getSingletonInstance(); } } sealed class Singleton { private static Singleton \_s = null; public int instanceCount; private Singleton() { //do nothing } public static Singleton getSingletonInstance() { if (\_s == null) { \_s = new Singleton(); } return \_s; } }
}
Put the breakpoint on line
if (_s == null)
and then observe the behavior when we do something likes2 = Singleton.getSingletonInstance();
When the breakpoint will hit, try watching the value of _s. The watch window will pop endlessly all over the screen when you click on the following + sign next to the static members icon. Screenshot : http://bp1.blogger.com/_J8sDhLDCDXA/SHv7z5Sx0RI/AAAAAAAAAIA/8xubz88GBJM/s1600-h/debugger.JPG Any clue why?It's not exactly a subtle bug is it? Despite this being called the subtle bugs forum, and not the "let's try to get somebody to sort my problems out for me forum".
Deja View - the feeling that you've seen this post before.
-
It's not exactly a subtle bug is it? Despite this being called the subtle bugs forum, and not the "let's try to get somebody to sort my problems out for me forum".
Deja View - the feeling that you've seen this post before.
I doubt the OP posted looking for help.
-
It's not exactly a subtle bug is it? Despite this being called the subtle bugs forum, and not the "let's try to get somebody to sort my problems out for me forum".
Deja View - the feeling that you've seen this post before.
Not sure of the OP's real intent. Too hard to tell today :laugh:
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
I doubt the OP posted looking for help.
Brady Kelly wrote:
I doubt the OP posted looking for help
From the OP: "Any clue why?". It's at the bottom of his post.
Deja View - the feeling that you've seen this post before.
-
Brady Kelly wrote:
I doubt the OP posted looking for help
From the OP: "Any clue why?". It's at the bottom of his post.
Deja View - the feeling that you've seen this post before.
It took you this long to find that evidence? Methinks Pete doth protest too much. ;P
-
It took you this long to find that evidence? Methinks Pete doth protest too much. ;P
Brady Kelly wrote:
Methinks Pete doth protest too much.
:laugh: Methinks Pete switches email notifications off.
Deja View - the feeling that you've seen this post before.
-
Look at the simple code below
using System;
namespace Pattern
{
class Program
{
static void Main(string[] args)
{
Singleton s1, s2;s1 = Singleton.getSingletonInstance(); s1.instanceCount = 100; s2 = Singleton.getSingletonInstance(); } } sealed class Singleton { private static Singleton \_s = null; public int instanceCount; private Singleton() { //do nothing } public static Singleton getSingletonInstance() { if (\_s == null) { \_s = new Singleton(); } return \_s; } }
}
Put the breakpoint on line
if (_s == null)
and then observe the behavior when we do something likes2 = Singleton.getSingletonInstance();
When the breakpoint will hit, try watching the value of _s. The watch window will pop endlessly all over the screen when you click on the following + sign next to the static members icon. Screenshot : http://bp1.blogger.com/_J8sDhLDCDXA/SHv7z5Sx0RI/AAAAAAAAAIA/8xubz88GBJM/s1600-h/debugger.JPG Any clue why?Judging by the screenshot, I assumed VS would open the watch windows by itself ;P Anyway, for my it just crashed after opening what was apparently one too many of these watch windows. I did have other cases where something similar happened, but I don't think I have still have the code, it's already fixed.