M
Mark Prenter
Hi, I've got a question about .NET and pointer scope. Basically I'm trying
to find out how smart .NET is with it's garbage collection and realizing
when a variable is no longer used.
For the sake of this question, regardless of poor programming practices,
lets say I have a custom object which has a public variable called "fs"
which will be a pointer to a FileSteam (FileStream*). And then lets say
that in one of my functions, I create a different FileStream, call it "fs2",
but point "fs" to "fs2", so that both FileStream pointers are pointing at
the same FileStream object.
I would assume, that at the end of the function, "fs2" should go out of
scope. Is .NET smart enough to realize that "fs" is still pointing to the
object and not garbage collect it? Or will it eventually be garbage
collected, leaving "fs" pointing to nothing?
/\/\ark
to find out how smart .NET is with it's garbage collection and realizing
when a variable is no longer used.
For the sake of this question, regardless of poor programming practices,
lets say I have a custom object which has a public variable called "fs"
which will be a pointer to a FileSteam (FileStream*). And then lets say
that in one of my functions, I create a different FileStream, call it "fs2",
but point "fs" to "fs2", so that both FileStream pointers are pointing at
the same FileStream object.
I would assume, that at the end of the function, "fs2" should go out of
scope. Is .NET smart enough to realize that "fs" is still pointing to the
object and not garbage collect it? Or will it eventually be garbage
collected, leaving "fs" pointing to nothing?
/\/\ark