Welcome to Scripting Forums Sign in | Join | Help
in Search

Alternative to FreeMem using Object Model and VBScript and WMI

Last post 12-15-2007, 1:51 PM by AlexKAngelopoulos. 5 replies.
Sort Posts: Previous Next
  •  11-24-2007, 8:03 PM 28908

    Alternative to FreeMem using Object Model and VBScript and WMI

    I know that VBScripts allows to make:

    {
    FreeMem=Space(256000000)
    }

    This will free 256 MB of RAM... How can I do this from inside a VBS script, using Object Model + WMI? Could you please an VBS sample?


    Thanks in advance.

    Regards.
  •  11-28-2007, 2:04 PM 28951 in reply to 28908

    Re: Alternative to FreeMem using Object Model and VBScript and WMI

    Hi asgarcymed,

    There's no scriptable method that I know about that can "free" memory -- the only way to really "free" memory is to stop unneeded processes, and Windows' built-in memory manager handles memory allocation for you. What exactly are you trying to do?

    Bill

  •  11-30-2007, 5:39 AM 28965 in reply to 28951

    Re: Alternative to FreeMem using Object Model and VBScript and WMI

    I am trying to run a script which analyzes thousands of files, and thus, it is very CPU and RAM consumer... When I run it for a small number of files, no problems; however it "eats" all RAM when number of files > 500...

     

    Regards. 

  •  12-04-2007, 2:42 PM 28981 in reply to 28965

    Re: Alternative to FreeMem using Object Model and VBScript and WMI

    Hi asgarcymed,

    As I said, there are no script APIs (that I know of, anyway) that allow you to "free" memory. In addition, the notion of "free" memory is not really that straightforward. For example, Windows handles swap file space as an extension of physical memory. I think you're stuck with closing programs you don't need or optimizing your script.

    Bill

  •  12-07-2007, 9:37 AM 29007 in reply to 28981

    Re: Alternative to FreeMem using Object Model and VBScript and WMI

    :(
  •  12-15-2007, 1:51 PM 29072 in reply to 29007

    Re: Alternative to FreeMem using Object Model and VBScript and WMI

    If you don't mind posting your code, it's possible that we could point out where the problem causing major memory consumption is. In all likelihood, it comes down to one of the following:

    1. Recursively enumerating files and folders and keeping a handle to them before performing processing. Rewriting your code to stream the content could improve things substantially. So could off-loading file/folder recursion - that gets really messy in WSH, but a commandline WSH script that reads its input stream can off-load all of the recursive enumeration by using the command shell dir command properly - for example, using
      dir /a /s /b
      enumerates all files and folders recursively and returns them as paths, one per line, and they get used and dumped quickly
    2. Another problem might be your string manipulation, if you're actually doing something with text from those files. Although VBScript is fairly fast with small strings and arrays, its approach to dynamic arrays and string-building scales horribly; it actually creates a complete new copy under the covers each time it adds text to a string or a new element to an array. Between increasing data set size and the number of operations it performs, the speed slows exponentially with respect to array/string length.
View as RSS news feed in XML
SPONSORED LINKS FEATURED LINKS

Free Download –VS 2008 TrainingExperts Ken Getz & Robert Green plus labs, code, courseware Maximize speed, performance and reliablity of your PCs and servers—automatically!Speed Up Your PC! Try Diskeeper 2008 with InvisiTasking Free Now! Register for SolarWinds VM MonitorGet X-Ray Vision into Your ESX Servers with SolarWinds FREE VM Monitor GoGrid Offers FREE Trial for Windows Cloud ServersDeploy Windows Server 2003 and 2008 with free load balancing through GoGrid’s award winning web-based GUI – all in less than 5 minutes Order Your SQL Fundamentals CD Today! Learn how to use SQL Server, understand Office integration techniques and dive into the essentials of SQL Express and Visual Basic with this free SQL Fundamentals CD. How healthy is your Exchange Server? Find out Now!Automatic Exchange Server Maintenance helps prevent disasters and improves performance. Download a FREE Exchange Server analysis tool. You've Deployed SharePoint...Now What?This one-day free online conference delivers the technical knowledge needed to kick MOSS up a notch. In one information-packed day, independent SharePoint experts will present practical, real-world information and provide take-away, ready-to-use solutions Ease Your Scripting Pains with the Flexibility of PowerShell!Paul Robichaux equips you with PowerShell basics in 3 introductory lessons, each followed by live Q&A—all on your own computer! Register today! What Would You Do If You Ran Microsoft?ITTV's 2008 inaugural video contest, "If I Ran Microsoft..." is your chance to tell it like it is. Be goofy or be serious, but don"t miss this chance to have fun, win prizes, and go viral in a major way. Maximize Your SharePoint InvestmentThis web seminar discusses how true bi-directional replication of SharePoint content from one server to another enables branch offices to maintain access to current SharePoint content. Rock Your Knowledge, and Compete with Friends and Colleagues!Are you the Web Application Performance Guru in your office? It's time to have fun! Download now to access the crossword puzzle. Challenge yourself and complete this fun activity!

 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing