Re: vbs output to txt file
- From: "Paul Baker [MVP, Windows - SDK]" <paulb@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 11 Apr 2007 13:26:14 -0400
Most of the people I work with do not express an opinion about "set obj =
nothing" (even when the variable "obj" is about to go out of scope). Every
one of those that does insists that I must do it. I argue with them every
time and I refuse to do what they say. Not because I read anything that
tells me one way or another. Just because to me it's obvious that their
arguments are bogus.
These objects are COM objects and reference counted through the IUnknown.
Going out of scope is a decrement of the reference count. Just because it is
not obvious that VB or VBScript is doing all this magic for you doesn't mean
that it is not.
Paul
"mr_unreliable" <kindlyReplyToNewsgroup@xxxxxxxxxxx> wrote in message
news:uUYEnyFfHHA.3632@xxxxxxxxxxxxxxxxxxxxxxx
Al Dunbar wrote:
There is a school of thought that says this is not actually required to
do this religiously in all cases. As I understand it, when a function or
sub returns, or a script ends, the script engine effectively releases all
object variables going out of scope.
Here is a link to Eric Lippert's (ms employee and scripting
engine developer) famous blog, saying that setting objects
to nothing is a waste of time (and also making very dis-respectful
comments about anybody who does):
http://blogs.msdn.com/ericlippert/archive/2004/04/28/122259.aspx
As for myself, I religiously set objects to nothing when finished
with them, and so am seriously lacking in both scripting expertise
and mental capacity, at least according to Eric.
This peculiarity is partially due to initially copying code out
of the scripting documentation, where set object = nothing is
routinely used. It was subsequently reinforced by moving over
to the system api world, where failing to release any system
objects resulted in "memory leaks", and if allowed to persist
"memory leaks" can bring down hour system. So a habit of
explicitly releasing objects was developed. And finally, there
is just a slight bit of counter-culture sympathy at work here.
That is, if a microsoft expert says DON'T DO IT (set obj = nothing),
then I take some perverse satisfaction going against the
prevailing wisdom. I guess that ends any possibility of ever
having a career with microsoft...
cheers, jw
____________________________________________________________
You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)
.
- Follow-Ups:
- Re: vbs output to txt file
- From: Al Dunbar
- Re: vbs output to txt file
- From: TheScriptLibrary.com
- Re: vbs output to txt file
- References:
- vbs output to txt file
- From: Cactus Johnson
- Re: vbs output to txt file
- From: Richard Mueller [MVP]
- Re: vbs output to txt file
- From: TheScriptLibrary.com
- Re: vbs output to txt file
- From: Al Dunbar
- Re: vbs output to txt file
- From: mr_unreliable
- vbs output to txt file
- Prev by Date: Re: Allocation Units
- Next by Date: Re: How can I get "Computer description" ?
- Previous by thread: Re: vbs output to txt file
- Next by thread: Re: vbs output to txt file
- Index(es):
Relevant Pages
|