Garbage Collection - Pointer out of scope, or not?
From: Mark Prenter (sorry_at_toomuchspam.com)
Date: 07/23/04
- Next message: bikerider7: "DLL Hell"
- Previous message: Craig Klementowski: "enum handling change in VS 2005"
- Next in thread: Ronald Laeremans [MSFT]: "Re: Garbage Collection - Pointer out of scope, or not?"
- Reply: Ronald Laeremans [MSFT]: "Re: Garbage Collection - Pointer out of scope, or not?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 23 Jul 2004 11:16:05 -0700
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
- Next message: bikerider7: "DLL Hell"
- Previous message: Craig Klementowski: "enum handling change in VS 2005"
- Next in thread: Ronald Laeremans [MSFT]: "Re: Garbage Collection - Pointer out of scope, or not?"
- Reply: Ronald Laeremans [MSFT]: "Re: Garbage Collection - Pointer out of scope, or not?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|