Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


January 2004

The Memory-Optimization Hoax

RAM optimizers make false promises
RSS
Subscribe to Windows IT Pro | See More Internals and Architecture Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Available Memory
I stated earlier that the Memory Manager gives a page of available physical memory to a process that experiences a page fault, but I haven't told you what defines available memory. The standby list is part of physical memory that the Memory Manager considers to be available. The other pools that contribute to available memory are pages that contain data belonging to deallocated virtual memory (e.g., pages containing data that belongs to processes that have exited) and pages that were freed and subsequently filled with zero data by the Memory Manager's low-priority zero page thread. Those types of pages are stored on the Memory Manager's free list and zeroed page list, respectively.

Figure 2 shows the transitions that occur between working sets and the page lists. Once per second, a system thread wakes up and calls the Memory Manager's working set manager to examine the System and processes' working sets. If available memory is low, the working set manager removes pages from the processes that haven't incurred many page faults in the past second. The removed pages go to the modified or standby list as appropriate and contribute to available memory. An important side effect of this tuning mechanism is that if the system needs memory for other processes, the Memory Manager takes pages from idle processes' working sets. Thus, those working sets eventually disappear, meaning that processes that remain idle for a sufficient length of time eventually consume no physical memory.

When a process needs a new page of physical memory, the Memory Manager first determines whether the page the process is accessing is in the standby or modified page list. The page will be in one of these lists if the page was removed from the process working set and not reused for another purpose. Placing that page back into the process working set is called a soft page fault because, unlike hard page faults, it doesn't involve a read from the paging file or other file on disk.

If the page isn't in the standby list or the modified page list, the Memory Manager takes a page from a list that has a page on it, checking first the free list, then the zeroed page list, and finally the standby list. If no memory is available, the Memory Manager triggers the Balance Set Manager to trim the process working sets and populate one of the three lists that make up available memory. If the Memory Manager has to remove a page from the zeroed page, free, or standby list for reuse, it determines how to access the targeted code or data, which can include reading the data from a paging file or an executable image or creating zero-filled data—if the application is allocating fresh data and the page taken wasn't from the zeroed page list.

Creating Available Memory
With that understanding of the Memory Manager's behavior, we can now turn our attention to the workings of RAM optimizers. The available-memory value that RAM optimizers display is the same value that the Task Manager shows as Available in the Physical Memory section on the Performance tab, which Figure 3 shows. That value is the sum of the sizes of the standby, zeroed page, and free lists. System Cache is the sum of the sizes of the standby list and the System working set. (In Windows NT 4.0 and earlier, File Cache reflects the size of only the System working set.)

RAM optimizers take advantage of the Memory Manager's behavior by allocating, then freeing, large amounts of virtual memory. Figure 4, page 21, shows the effect a RAM optimizer has on a system. The first bar depicts the working sets and available memory before optimization. The second bar shows that the RAM optimizer creates a high memory demand, which it does by incurring many page faults in a short time. In response, the Memory Manager increases the optimizer's working set. This working-set expansion occurs at the expense of available memory and—when available memory becomes low—at the expense of other processes' working sets. The third bar illustrates how, after the RAM optimizer frees its memory, the Memory Manager moves all the pages that were assigned to the RAM optimizer to the free list, thus contributing to the available-memory value. Most optimizers hide the rapid decline in available memory that occurs during the first step, but if you run Task Manager during an optimization, you can often see the decline as it takes place.

Although gaining more available memory might seem beneficial, it isn't. As RAM optimizers force the available-memory counter up, they force other processes' data and code out of memory. Say that you're running Word, for example. As the optimizer forces the available-memory counter up, the text of open documents and the program code that was part of Word's working set before the optimization (and was therefore present in physical memory) must be reread from disk as you continue to edit your document. The performance degradation can be severe on servers because the file data that's cached in the standby list and in the System working set (as well as the code and data used by active server applications) might be discarded.

Other RAM Optimizer Claims
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. All such claims are untrue because Windows automatically trims idle processes' working sets. The Memory Manager handles all necessary memory optimization.

Developers of RAM optimizers also claim that their products defragment memory. The act of allocating, then freeing a large amount of virtual memory might, as a conceivable side effect, lead to blocks of contiguous available memory. However, because virtual memory masks the layout of physical memory from processes, processes can't directly benefit from having virtual memory backed by contiguous physical memory. As processes execute and undergo working-set trimming and growth, their virtual-memory–to–physical-memory mappings will become fragmented despite the availability of contiguous memory.

Having contiguous available memory can improve performance in one case: when the Memory Manager, to maximize the behavior of the CPU memory caches, uses a mechanism called page coloring to decide which page from the free or zeroed page list to assign to a process. However, any minor benefit that might result from making available physical memory contiguous is heavily outweighed by the negative impact of discarding valuable code and data from memory.

Finally, vendors often claim that RAM optimizers regain memory lost to leaks. This claim is perhaps the most patently false assertion of all.

The Memory Manager knows at all times what physical and virtual memory belongs to a process. However, if a process allocates memory, then doesn't free it because of a bug (an occurrence known as a leak), the Memory Manager can't recognize that the allocated memory won't be accessed again at some point and must wait until the process exits to reclaim the memory.

Even in the event of a leaking process that doesn't exit, the Memory Manager's working-set trimming eventually will steal from the process's working set any physical pages that are assigned to leaked virtual memory. That process sends the leaked pages to the paging file and lets the system use physical memory for other purposes. Thus, a memory leak has only a limited impact on available physical memory. The real impact is on virtual-memory consumption (which Task Manager calls both PF Usage and Commit Charge). No utility can do anything about virtual-memory consumption other than kill processes that are consuming memory.

Fraudware
I have yet to see a RAM optimizer that lives up to any of its claims. If you look closely, you'll often see that vendors have buried long-winded disclaimers on their Web sites that state what I've explained—that the product might not have any impact on a system's performance and might actually degrade it. Even without knowing how these products take advantage of the Memory Manager to inflate a highly visible and provocatively named memory metric, common sense suggests that if RAM optimization were possible (and could be implemented by so many small-time upstarts), Microsoft developers would have long since integrated the technology into the kernel.

End of Article

   Previous  1  [2]  Next  


Reader Comments
Regarding Mark Russinovich's technically detailed and otherwise excellent article Internals: "The Memory-Optimization Hoax" (January 2004, http://www.winnetmag.com, InstantDoc ID 41095), which debunks memory "optimization" utilities, I have just one comment: Free memory is the enemy of true performance. <P>
This statement might strike many computer users as ridiculous, but with explanation it makes sense. Mark's article touches on this concept but then buries it under technicalities. If my OS isn't using all its memory, it's not using my machine to full capacity. Yes, a small portion of memory must remain unallocated to give the system room to work in, but all the rest
of the memory should be used. I'm not referring to a situation such as running the system at near-maximum capacity and filling the entire virtual memory subsystem with a data set. I'm referring to modern, lightly loaded systems with large amounts of excess physical RAM that under usual circumstances will never be completely used. Ideally, the OS should use such excess RAM for caching, reallocating it only as needed. If the OS aggressively frees memory for some unknown future need, then data that the OS could have retrieved from RAM will instead require a disk read, incurring a massive performance penalty.<P>
I became aware of this counterintuitive concept when I began to use FreeBSD. I learned from a Usenet thread that near 100 percent memory usage is not only "normal" but indicative of a properly working system. Now, I measure an OS not only by how much memory it keeps free but also by how much it uses. I realize that the situation is a bit more complicated than I've described, but my point is that free memory is not your friend. You paid good money for your RAM. Do you really want it to be unused? <P>

I agree that an OS's job is to give memory to processes running on a system so that the processes can run efficiently and that this job requires using all physical memory. However, as I stated in my article, the Windows Memory Manager allocates memory by effectively using all "free" memory for cached file data, which the standby list stores. The Memory Manager uses this system to assign to certain processes only the memory they actually need so that other processes can get the memory that they actually need. One way the Memory Manager accomplishes this goal is by taking memory away from a process that doesn't need it and placing the unneeded memory on the standby list. If that process requests data from the standby list, it receives the data immediately; however, the memory demands of other processes might require that they also take memory from the standby list. The standby list serves as the file-system and paging-file cache, and even though memory on the list is considered "available," it's nevertheless actively used and therefore doesn't fit Henry's definition of free memory. <br>
--Mark Russinovich

Henry Mason January 23, 2004


I agree 99 % with your analysis. However, the Windows memory management algorithm is not perfect (who, err, which is?:). Consequently, in rare circumstances, brute-forcing pages out of physical memory might actually improve performance of some applications. For a - somewhat related - discussion on Linux's VMM logic, the discussion on http://lwn.net/Articles/83588/ might be interesting ( I am not qualified to judge Windows's against Linux's MM).

Andreas June 11, 2004


I would agree that some claims are frivolous or incorrect, however to state the creating more Available Memory doesn't help is incorrect IMO.For gamers forcing other processes out of memory to the VM is a good thing. Not everyone likes to use Task Manager to End Processs. One game for example is Planetside. Its a fun game, but a major resource hog, the more Free Memory you can throw at it the better, and the pause after quitting to get back to the desk as the system unpages other stuff is fine with me. It shows that the utility did exactly what I wanted it to do, which was free memory for use by the game. As for Memory Leaks not being helped, I'll study more on that one. While it may not fix the memory leak issue, even forcing the unused data to the VM so that the process can use more Physical Memory again is a good thing. It speeds things back up. Though, I'll agree that the only real fix is to restart the applications from time to time if not even restarting Windows.

Players of Planetside and other games will agree the more memory the better. If your claim that more Available Memory not being beneficial was correct, with regards to gaming, then most all Gamers (who lead the push for higher end PC parts)are all wrong for running 1Gb + of memory to increase performance. We should all be happy as clams with 512Mb as we can just page everything to VM and run it from there.

If you decide to argue that gamers don't make up a large portion of the computing community you again would be wrong. Its a multiBillion dollar industry that is only getting bigger as time goes on.

I will agree a desktop user running Word, Browswers, email, etc prob wouldn't find these Utilities useful, I think they can have a place of usefulness in the gaming Community for games we love that happen to be RAM HOGS.

Greg Waggoner June 13, 2004


Criticism is good but do you have solution for freeing RAM when my comp is slow with 512 MB of RAM? If it's true that memory management frees up my RAM after process exit, why is my RAM so occupied? Windows is not as perfect as you write in your article. They also have many bugs and some of your claims are not true at all.

Miro June 14, 2004


I agree with the problem with these "memory optimizers" - I've tried some and they claim it works, but I don't notice or gain anything. For gamers like myself, though (and anyone that wants to free up more memory), more memory is key. And so is reducing the CPU cycles taken up by unnecessary programs. Going through Task Manager is a pain, but a co-worker told me about this software called TAG. I downloaded it, ran it, and it did a real nice job of clearing things out of memory and loaded them back in when I was done playing. It doesn't claim to be one of these "force memory to disk and then unload it" and they say so on their website. Just want to throw in my 2 cents of what I've found that actually works.

Jenna July 01, 2004


I agree with your comments on the Memory Management process.
What I recommend to enhance your Windows experience is to de-activate any useless "Startup program" or "Service".

Good links to find more on these points are:
== 12 Tweaks for performance (+ help to disable services)
http://www.blackviper.com/WinXP/supertweaks.htm
== Utility to disable Startup Applications
http://www.sysinternals.com/ntw2k/freeware/autoruns.shtml
== List of Startup Applications
http://www.pacs-portal.co.uk/startup_index.htm

And, if you need a RAM Optimizer (because you run Windows 95/98/ME), you can use this little one.
It has a very small memory footprint.
http://www.jfitz.com/software/RAMpage/
I quote from the FAQ:
"Note that NT, 2000 and XP are all based on the NT kernel. There is no compelling evidence to suggest that freeing memory does anything to improve performance or reliability on these systems, (in fact it will generally have a minor negative impact on performance). These versions also include memory monitoring screens in the Task Manager, so I don't think there is much point running RAMpage on these systems."

Florent July 03, 2004


There's hundreds or even thousands of registry tweaks available for free on the net. Don't pay a dime for tweaking programs eaither.

Joe July 03, 2004


Does the program Cache Boost fall into the category of memory optimizer?

Cacheboost optimizes the System Cache-Management of Windows XP/2000/NT and Windows .Net Servers. This results in an best performance boost - without any new hardware, any hardware tweak, and without restricting your system's stability. Simply install Cacheboost and you are ready to go. No special configuration or rebooting is needed. Within minutes you activate unused resources of your Windows XP/NT/2000 and Windows .Net systems.

CODE
More Info:

http://www.systweak.com/cacheboost/overview.asp

Doug July 04, 2004


I would like to know your opinion about all those claims of "perfect" memory management and memory compactation that RDBMS like Oracle claims. It isn't real memory masked behind virtual memory? What kind of memory compactation they do, if they relay in virtual memory paging?

Jorge July 05, 2004


hey guys - i might be getting off the topic a bit here but can't resist putting this in...

over the years i have noticed that when doing a ctrl-shift-esc (start task manager) explorer memory size can be quit large (click on memory column to sort by size). i have found the best way to fix this problem (aside from the obvious "reboot fixes 9 out of 10 problems) is to 'end task' on explorer then do a 'file' 'new task' and type explorer. this starts a new instance of explorer with a lot smaller footprint (also save yourself $9.95)!!

smeg July 05, 2004


 See More Comments  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   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200   201   202   203   204   205   206   207   208   209   210   211   212   213   214   215   216   217 

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Friday at PASS Europe 2006

Kevin talks about the closing day of the event and shares a funny Microsoft film. ...

The Memory-Optimization Hoax

Don't believe the hype. At best, RAM optimizers have no effect. At worst, they seriously degrade performance. ...

More fun TechEd 2005 Resources

Kevin points out some more TechEd resources ...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Are You Satisfied?

A Preliminary Look at Deployment Plans for Microsoft Windows Vista

Related Events Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.

Job Openings in IT


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

IT Connections
Dive into the new Microsoft platforms and products you implement and support with the experts from Microsoft, TechNet Magazine, Windows ITPro and industry gurus. There are 70+ sessions and interactive panels with networking opportunities.

Attention User Group Leaders...
Announcing the eNews Generator—a FREE HTML e-newsletter builder for user group leaders. Build your HTML and text e-newsletters in minutes and add Windows IT Pro & SQL Server Mag articles alongside your own message!.

Master SharePoint with 3 eLearning Seminars
Learn how to build a better SharePoint infrastructure and enable powerful collaboration with MVPs Dan Holme and Michael Noel. Register today!

Get SQL Server 2008 at WinConnections
Don’t miss Microsoft Exchange and Windows Connections conferences, the premier events for Microsoft IT Professionals in Las Vegas, November 10-13. Every attendee will receive a copy of SQL Server 2008 Standard Edition with one CAL.



Interested in Email Encryption?
Read about the advantages of identity-based encryption in this free report.

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.

Virtualization Congress Oct. 14-16 in London
Don't miss Virtualization Congress, the premiere EMEA conference dedicated to hardware, OS and application virtualization. Oct. 14-16.
Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technical Resources Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing