Re: Can com+ Hotfix Rollup Package 27 fix my memory problem with WSH. CreateObject/CreateScript?
From: Al Dunbar [MS-MVP] (alan-no-drub-spam_at_hotmail.com)
Date: 11/26/04
- Next message: venkatgmail: "How can I execute Activex on IE without downloading my third party DLL into client sy"
- Previous message: ben h: "Re: object=nothing question"
- In reply to: Gerry Hickman: "Re: Can com+ Hotfix Rollup Package 27 fix my memory problem with WSH. CreateObject/CreateScript?"
- Next in thread: Gerry Hickman: "Re: Can com+ Hotfix Rollup Package 27 fix my memory problem with WSH. CreateObject/CreateScript?"
- Reply: Gerry Hickman: "Re: Can com+ Hotfix Rollup Package 27 fix my memory problem with WSH. CreateObject/CreateScript?"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 25 Nov 2004 18:32:24 -0700
"Gerry Hickman" <gerry666uk@yahoo.co.uk> wrote in message
news:OubZQem0EHA.3292@TK2MSFTNGP10.phx.gbl...
> Al Dunbar [MS-MVP] wrote:
>
> > Ouch! my face is still stinging from this slap, however well deserved it
> > might be!
>
> Heh, well it wasn't aimed at you:)
Heh, improve your aim, then... ;-)
> > I agree with *most* of what you say above (mainly the importance of
> > <explicitly> closing files, recordsets, and connections), mainly because
> > these activities have effects that are felt outside of the scope of a
script
> > by an object that has its own existence in that external domain.
>
> Yes.
>
> > Contrariwise, it seems to me that the de-instantiation of objects is
done
> > automatically by WSH. I just did a test using a class created for the
> > purpose, which indicates that its terminate event is invoked by any of
the
> > following:
>
> We don't have this hand-holding "terminate" event in JScript so it's the
> first time I've seen it, but I don't think it changes much. You can put
> your clean-up code in the "terminate" event if you like, but at the end
> of the day, it's no different to calling Dispose() manually. You'd have
> to do it that way in COM anyway. Of course in script, the object will be
> destroyed sooner or later, but with a long script with looping you
> ignore best practice at your own risk.
The difference is, if it is someone else's class (or COM object) we are
using and they have done it "right", we will not have to explicitly Dispose,
or explicitly do anything.
> > to the same object, memory and system resources associated with the
object
> > to which the variables refer are released only after all of them have
been
> > set to Nothing, either explicitly using Set, or implicitly after the
last
> > object variable set to Nothing goes out of scope."
> > Even the above definition makes no distinction between object variables
> > being set to nothing and going out of scope, other than to call one
explicit
> > and the other implicit.
>
> I know and I agree. I think you've looked into it in much greater depth
> than I have, and I'm in no doubt your code releases everything
> perfectly.
Very flattering, but I make no claims of perfection...
> However:
>
> What I'm saying is much more basic than that. I haven't gone into
> details and probably don't need to, what I'm saying is that no one needs
> to worry about this, because if they follow best practice as outlined in
> my earlier message, they'll never run into this problem in the first
> place. Why take a risk if you don't need to? People are going to have to
> program this way as soon as they look outside VBScript, so why not start
> now?
Now we're talking the same language (as if you thought we ever would! ;-). I
agree that following best practice is almost always worth the extra effort -
in fact, in the long run it reduces the effort. But this applies to a number
of aspects of coding practice in addition to releasing all objects when they
are no longer required. It would be silly, in my view, to insist religiously
on that one aspect while ignoring the others. I think the best approach is a
balance among them all.
> As an example of not calling Dispose(), I have a class called Reg() that
> is all about managing remote registries. Reading and Writing dozens of
> values to hundreds of machines is a walk in the park, but what it can't
> do (for performance reasons) is close the connection until I call the
> destructor. If I don't call it, I'll have a gazillion network sessions
> open on my network - not good. Obviously I don't want to open and close
> a connection every time I read or write a key, so it's catch-22. That's
> why I open the connection once, do the work, and the close it once. In
> COM there's even a reference counter for this. Scripters should
> implement their own reference counter and pretend they're programming in
> COM.
Certainly a good suggestion in the context of the type of script you are
talking about here.
> If people don't want to follow this advice that's fine, as long as they
> don't start complaining!
If they don't follow the advice, what have they to complain about?
> WSH is not as fool-proof as some people think. For example if you exec
> "SLEECT * FROM CIM_DataFile" on a modern computer with a few mapped
> drives, you could find yourself with a processor intensive process
> running solid for over two hours - hit CTRL+C in cscript and your script
> will stop (kind of), but it won't stop that process eating all your
> resources for the next two hours.
Is that an indication of a weakness on WSH's part, or of the WMI
infrastructure (or whatever) that is providing the query functionality?
/Al
- Next message: venkatgmail: "How can I execute Activex on IE without downloading my third party DLL into client sy"
- Previous message: ben h: "Re: object=nothing question"
- In reply to: Gerry Hickman: "Re: Can com+ Hotfix Rollup Package 27 fix my memory problem with WSH. CreateObject/CreateScript?"
- Next in thread: Gerry Hickman: "Re: Can com+ Hotfix Rollup Package 27 fix my memory problem with WSH. CreateObject/CreateScript?"
- Reply: Gerry Hickman: "Re: Can com+ Hotfix Rollup Package 27 fix my memory problem with WSH. CreateObject/CreateScript?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|