String Init
From: Alvin Bruney [MVP] (vapor)
Date: 02/09/04
- Next message: hp: "RE: create odbc connection on the fly"
- Previous message: Shardool Karnik: "Re: Most Difficult to Programme"
- Next in thread: Jon Skeet [C# MVP]: "Re: String Init"
- Reply: Jon Skeet [C# MVP]: "Re: String Init"
- Reply: Stu Smith: "Re: String Init"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 9 Feb 2004 15:22:26 -0600
Sometime ago, i posted a concern about initializing string variables to null
v string.empty. I can't find the thread to reply to it so excuse this one.
I just now thought of this. Isn't it dangerous to initialize variables to
null in a garbage collected environment since garbage collection is
non-dert...yada yada yada.
Consider this, i have a routine spanning 200 lines of code. at the top of
the routine i intialize an object to null. I intend to use this variable at
line 160 for example. At line 10, a garbage collection occurs. Is my code at
line 160 safe, the object is eligible for garbage collection because it has
no roots? This is theoretical and not apt to occur frequently but, right
now, i'm thinking this is terrible if it can actually occur. (haven't given
it much thought just yet)
wouldn't it be best to intialize an object to a root like empty which would
prevent this situation from occuring?
-- Regards, Alvin Bruney [ASP.NET MVP] Got tidbits? Get it here... http://tinyurl.com/3he3b
- Next message: hp: "RE: create odbc connection on the fly"
- Previous message: Shardool Karnik: "Re: Most Difficult to Programme"
- Next in thread: Jon Skeet [C# MVP]: "Re: String Init"
- Reply: Jon Skeet [C# MVP]: "Re: String Init"
- Reply: Stu Smith: "Re: String Init"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|