Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Memory usage for Cscript

Reply
 
Old 01-05-2009   #1 (permalink)
Bob Smith


 
 

Memory usage for Cscript

I have a script I wrote that basically performs a loop indefinably using
wscript.sleep. The script performs the same action over and over again every
10 minutes. What is interesting to me however; if I fire the script off using
cscript.exe it initially uses about 8MB or ram (as shown in the task
manager). After the script has been running 4 - 5 days I checked again and
it's using 500k. It seems strange to me that this would happen. Is this
normal behavior?

My System SpecsSystem Spec
Old 01-05-2009   #2 (permalink)
Al Dunbar


 
 

Re: Memory usage for Cscript


"Bob Smith" <BobSmith@xxxxxx> wrote in message
news:B93BD40F-4994-488B-8A24-E5C77ABC55E0@xxxxxx
Quote:

>I have a script I wrote that basically performs a loop indefinably using
> wscript.sleep. The script performs the same action over and over again
> every
> 10 minutes. What is interesting to me however; if I fire the script off
> using
> cscript.exe it initially uses about 8MB or ram (as shown in the task
> manager). After the script has been running 4 - 5 days I checked again and
> it's using 500k. It seems strange to me that this would happen. Is this
> normal behavior?
That depends.

This should be considered normal behaviour for a script that consumes memory
by REDIM'ing arrays, creating unnecessary objects, or doing some sort of
string concatenation that does not properly release memory. What, precisely
is your script doing? If short, try posting it here.

/Al


My System SpecsSystem Spec
Old 01-06-2009   #3 (permalink)
Bob Smith


 
 

Re: Memory usage for Cscript

I would refer to this script as more like an application than a script. I
like to push VB script to it's limits. Yes I do have arrays that I redim, I
also have Many objects that perform differing tasks (open CDO mailboxes with
CDO, send emails, open databases etc). It's probably not the cleanest code,
but it gets the job done. I will not post the code as it is very long and not
well documented.

"Al Dunbar" wrote:
Quote:

>
> "Bob Smith" <BobSmith@xxxxxx> wrote in message
> news:B93BD40F-4994-488B-8A24-E5C77ABC55E0@xxxxxx
Quote:

> >I have a script I wrote that basically performs a loop indefinably using
> > wscript.sleep. The script performs the same action over and over again
> > every
> > 10 minutes. What is interesting to me however; if I fire the script off
> > using
> > cscript.exe it initially uses about 8MB or ram (as shown in the task
> > manager). After the script has been running 4 - 5 days I checked again and
> > it's using 500k. It seems strange to me that this would happen. Is this
> > normal behavior?
>
> That depends.
>
> This should be considered normal behaviour for a script that consumes memory
> by REDIM'ing arrays, creating unnecessary objects, or doing some sort of
> string concatenation that does not properly release memory. What, precisely
> is your script doing? If short, try posting it here.
>
> /Al
>
>
>
My System SpecsSystem Spec
Old 01-06-2009   #4 (permalink)
Al Dunbar


 
 

Re: Memory usage for Cscript


"Bob Smith" <BobSmith@xxxxxx> wrote in message
news:C797CC53-5638-4B87-BBDB-CCFC6FA5154F@xxxxxx
Quote:

>I would refer to this script as more like an application than a script. I
> like to push VB script to it's limits. Yes I do have arrays that I redim,
> I
> also have Many objects that perform differing tasks (open CDO mailboxes
> with
> CDO, send emails, open databases etc). It's probably not the cleanest
> code,
> but it gets the job done. I will not post the code as it is very long and
> not
> well documented.
Thanks for not posting ;-)

The answer seems to lie in this sentence: "It's probably not the cleanest
code, but it gets the job done". At some point you might find that your
"unclean" code will start failing to get the job done or causing other
problems because it is not cleaning up after itself by releasing resources
it has taken control of.

You could analyze your code looking for objects not set to nothing, objects
whose methods allow resources to be released (i.e. .close), iterative text
concatenation, and arrays redimmed ad infinitum, and address the specific
issue in each case. Hopefully your script (er, I mean "application") is well
enough structured that this can be done without radical surgery.

Of course, even if you were to do this, it would not guarantee that your
script would be free from resource issues. I don't know how good vbscript is
at garbage collection.

/Al
Quote:

> "Al Dunbar" wrote:
>
Quote:

>>
>> "Bob Smith" <BobSmith@xxxxxx> wrote in message
>> news:B93BD40F-4994-488B-8A24-E5C77ABC55E0@xxxxxx
Quote:

>> >I have a script I wrote that basically performs a loop indefinably using
>> > wscript.sleep. The script performs the same action over and over again
>> > every
>> > 10 minutes. What is interesting to me however; if I fire the script off
>> > using
>> > cscript.exe it initially uses about 8MB or ram (as shown in the task
>> > manager). After the script has been running 4 - 5 days I checked again
>> > and
>> > it's using 500k. It seems strange to me that this would happen. Is this
>> > normal behavior?
>>
>> That depends.
>>
>> This should be considered normal behaviour for a script that consumes
>> memory
>> by REDIM'ing arrays, creating unnecessary objects, or doing some sort of
>> string concatenation that does not properly release memory. What,
>> precisely
>> is your script doing? If short, try posting it here.
>>
>> /Al
>>
>>
>>

My System SpecsSystem Spec
Old 02-03-2009   #5 (permalink)
Python42


 
 

Re: Memory usage for Cscript

As an alternative to investing a lot of time in cleaning up the code, why
not make it a run-once application and use the windows task scheduler to
re-invoke it on a schedule? That way it wouldn't get the chance to amass a
lot of resources.


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Memory usage Vista General
Memory usage Vista performance & maintenance
Memory Usage... General Discussion
Memory Usage Vista General
Memory Usage Vista performance & maintenance


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46