Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternative to FreeMem using Object Model and VBScript and WMI

Status
Not open for further replies.

asgarcymed

Technical User
Nov 22, 2007
14
PT
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.
 
Space doesn't free RAM, it returns a string with the number of characters specified in the parameter, filled with spaces. Are you mixing this up with some other language? VBScript doesn't use {}.

Don't know about the WMI bit.
 
I used brackets just to isolate the VBS code snippet (VBS do not use brackets) in this post...

I am confused about Memory/RAM cleaning... I saw this FreeMem "trick"/"tip" while google's searching «How to Optimize PC's Memory in Real-Time»...
The majority of VBS books do not refer to «FreeMem=Space(bytes)»

Regards.
 
FreeMem=Space(256000000)
This will free 256 MB of RAM
Really ?
For me, this will EAT 256 MB of RAM ...
I wonder where you saw this.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Firstly, the original tip for this is for Windows 98 only, and secondly those original tips were based on a misunderstanding of how Windows 98 did memory management.

Basically, all you are doing is grabbing 256Mb of memory (if it is available) and then, because this is the only line in the script, freeing it as the script exits. This can give the apparant effect in a memory monitor of 'freeing' memory because it forces Windows 98 to do a garbage collection. However no real freeing of memory was occurring on W98, and it sure doesn't on any of the NT-based machines

 
Thank you for teaching me!
Can you suggest a valid and efficient alternative?
Regards.
 
Why exactly do you need to free that amount of RAM?

You can clear up

o objects by setting them to nothing
o arrays by redim or by declaring them in subs and funcs.
 
I am trying to make a script to examine thousands of files (path, size, date, md5 => write data to CSV file) and it consumes a lot of RAM when analyzing a big number of files. Thus, I need to create a clean RAM subroutine and run it cyclically...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top