Windows Vista Forums

Memory usage for Cscript

  1. #1


    Bob Smith Guest

    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

  2. #2


    Al Dunbar Guest

    Re: Memory usage for Cscript


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

    >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

  3. #3


    Bob Smith Guest

    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:

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

    > >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

  4. #4


    Al Dunbar Guest

    Re: Memory usage for Cscript


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

    >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

    > "Al Dunbar" wrote:
    >

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

    >> >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

  5. #5


    Python42 Guest

    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

Memory usage for Cscript

Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory usage dougdebonet Vista General 4 12 Apr 2009
Memory Usage... Tjingsted General Discussion 2 02 Feb 2008
Memory usage over 90% yang Vista performance & maintenance 7 13 Jul 2007
Memory Usage Curtis Vaughan Vista General 6 12 Jul 2007
Memory Usage Smilerfive Vista performance & maintenance 3 06 May 2007