Jump to content

[How-to] Reducing system memory usage


jftuga

Recommended Posts

I wrote a batch file to reduce memory usage on all running programs. This is done with empty.exe from the Win 2003 resource kit. This program calls APIs that frees the working set memory pages of running processes.

I have only run it on XP for a few months and it seems very stable. Some programs will eventually allocate more memory, but there are many background type programs that do not.

For some reason the message board will not allow me to upload the file (something about total filespace is greater that per post limit).

You can download it here:

http://www.fcs.uga.edu/~john/ReduceMemory_12.zip

I would appreciate any feedback.

-John

Edited by sonic
Link to comment
Share on other sites


I just figured out how to get rid of having to use egrep.exe. Change the batch file to read like this:

tasklist | gawk "tolower($1) !~ /csrss|smss|winlogon|lsass/ && $2 > 10 && $2 ~ /[0-9]/ {printf( \"%%05d\n\",$2)}" | sort | xargs -n1 empty

I changed the link in the first post to include this modification.

-John

Edited by jftuga
Link to comment
Share on other sites

hmm, shame as i aint seeing no difference even after verification :no:

try running each command step-by-step:

tasklist

tasklist | gawk ...

tasklist | gawk ... | sort

if you run it from the command-line, you will need to change %%05d to just %05d

After tasklist | gawk ... | sort, you should get a list of process IDs - 1 per line. You can run the empty.exe with one of these PIDs to see if it reduces memory. You may need SP2, but I am not sure.

-John

Link to comment
Share on other sites

I wrote a batch file to reduce memory usage on all running programs. This is done with empty.exe from the Win 2003 resource kit. This program calls APIs that frees the working set memory pages of running processes.

...

I would appreciate any feedback.

What is the reason for wanting to reduce the working set of all processes?

The working set manager thread is called by the balance set manager once per second as well as when the free memory falls below a certain threshold, and this handles the overall memory management policies such as working set trimming, aging and modified page writing.

There are "RAM optimizing" programs which have the same effect as your batch file but achieve it by trying to consume all available memory which forces agressive trimming of all process working sets, and then it relases it all.

The upshot is that they show "available memory" increases.

To quote Windows Internals:

While gaining more available memory might seem like a good thing, it isn't. As RAM optimizers force the available memory counter up, they force other processes' data and code out of memory. If you're running Word, for example, the text of open documents and the program code that was part of Words' working set before the optimization (and was therefore presetn in physical memory) must be reread from disks as you continue to edit your document.

...

Some vendors make additional claims for their RAM-optimizer products. One claim you might see is that a product frees memory that's needlessly consumed by unused processes, such as those that run in the Taskbar tray. That claim could only be true if those processes had sizable working sets at the time of optimization. However, because Windows automatically trims idle processes' working sets, all such claims are untrue. The memory manager handles all necessary memory optimization.

Link to comment
Share on other sites

Yeah, you free up RAM, but you're just flushing part of the process to disk - you don't actually reduce the memory usage of the process, just the RAM footprint. If you (or the system) go to load a process again, the necessary bits go back into RAM.

Not a bad idea, but may not be as useful as you'd like on a busy system.

Link to comment
Share on other sites

Thanks for the info Payne, but I want to know if there are possible side effects. Wouldnt 2 gigs of RAM and a clean reboot provide the best testing numbers as game benchers should be using real world scenarios and not a clean slate when testing?

Link to comment
Share on other sites

There's very few replacements for a clean and well oiled (tweaked) system.

Take the Kernal for instance. Windows will access that puppy sometimes several times a second.

If it's setting on a slow, fragmented, HD, you're in serious trouble.

Moving it up into RAM can do more to supercharge your system than just about anything else you can do.

I did this for myself a long time ago and regularly do it for all my customers.

Combined with a few more tweaks, it makes a real nice upgrade for any system running Windows XP.

Copy the text between the lines of *'s and paste into "Notepad". Then save as "XPTweaks.reg"

*********************************************

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Control Panel\Desktop]

"AutoEndTasks"="1"

"HungAppTimeout"="1000"

"WaitToKillAppTimeout"="1000"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control]

"WaitToKillServiceTimeout"="1000"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]

"DisablePagingExecutive"="1"

*********************************************

run it just once to tweak your registry. Reboot.

Your PC will shut down much quicker too.

Cheers,

Andromeda43 ;)

Link to comment
Share on other sites

This is known stuff. But helps for a lot of noobs. I have these tweaks enabled and several others that despite increasing the shutdown time, clears out all the contents of the pagefile. Keeps the machine sluggish-free.

Link to comment
Share on other sites

Yeah, I have these tweaks enabled too.

I guess for us it's buisness as usual, but for novice, it's a computer with Red Bull in his blood ;)

You are wrong regarding game benchmarkers, when it's tested for speed they clear everything posssible, to get max score posssible, beta testing game is done in normal enviroment but as a previous step

Link to comment
Share on other sites

Man this is good. I didn't read all the post but i've seen one that says something like, why should we do this, because as soon the app is in use again it will regain that freed memory, like that, why sould we, if u got some tray stored app. like Y! Messenger wich takes up like 25-40 mb for just sitting there minimized and many other, anyway i think this is great stuff, but not many see this, you can schedule to run say from 30 to 30 min or less/more.. i think you should try it out !

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...