Jump to content

Annoyance: "...run Disk Defragmenter now anyway?"


nospoon

Recommended Posts

If it would release my memory when I kill an app, I would be more satisfied. I even have the "force DLL to unload" option on and it still sux...or maybe it is the app that is the culprit? From what I have read, its all about the OS.
Windows does release the memory. After you close a program, the memory that was used is available to other programs.

What Windows does (and this is the thing that people get confused about), is that it doesn't erase the memory right away. Imagine the situation where you open a program, close it, then remember that you needed to do one more thing. When you run the program again, most of it is already in memory waiting for you. If the memory had been cleared, Windows would have to reload all the files from the hard drive.

If you want something done automatically, you need something running. It's as simple as that. You could also look into DIRMS and Buzzsaw. That might be another option for you, but then again, it's a service that runs all the time. Your choice.

Link to comment
Share on other sites


If it would release my memory when I kill an app, I would be more satisfied. I even have the "force DLL to unload" option on and it still sux...or maybe it is the app that is the culprit? From what I have read, its all about the OS.

Actually, you are correct. It is indeed the OS kernel that is responsible for memory management (unless the app was written in C++ and uses it's own memory management handlers, bypassing the NT memory manager, but I digress - I don't want to bore you :)). And you are correct, in general Windows XP doesn't release memory that an application has freed immediately. It waits for a time before it releases those memory addresses back into the available pool of virtual address space. Depending on what is running, what your commit charge is, the amount of physical RAM, your Paged and NonPaged kernel pool sizes and usage patterns, what kind of memory swings your system is seeing due to application memory usage, how many handles applications are using, how many threads the system is running, your page fault (hard and soft) deltas, the size of your page file (getting the idea yet? :rolleyes:), and also kernel vs usermode CPU usage patterns all determine how long Windows XP "holds" memory before freeing it back into the free memory pool.

Windows becomes more and more aggressive at releasing that "held" memory when the system starts to run low on virtual address space that can be mapped to actual physical memory - it will start releasing held memory quicker when the amount of address space mapped to physical RAM grows close to the full amount, and it will also start swapping out address space located in physical RAM to the pagefile to make sure that critical and running applications take preference in physical RAM over those that have been idle or are running in the background (in that order).

Again, the best book for understanding (and optimizing) the Windows kernel is "Windows Internals" (4th Edition). Get the hardcover if you can - I've worn out the binding on one already, and am on my second :).

Edited by cluberti
Link to comment
Share on other sites

@cluberti

Does the AlwaysUnloadDLL regtweak actually work in XP? I read somewhere that it doesn't?

(I have Windows internals too but unlike you I haven't read it all yet!)

It's a common misunderstanding about memory being released and that's probably why many people use such memory release utils.

Link to comment
Share on other sites

No, the AlwaysUnloadDLL tweak does work, but it only works on unloading .dll's from memory. Since most .dll's are under 1MB in size, it's more for developer testing to make sure a .dll has unloaded once it's done being used rather than for actually freeing up large amounts of memory.

Most people think that this tweak will magically free lots of memory, when in fact it will most likely not free ANY. The memory manager will still work the way it did before the tweak, it will just unload .dll's from memory - that memory address that the .dll held will most likely still be held by the memory manager for a time before it releases it back into the free pool, it's just the actual reference to the .dll in memory that is cleared.

Read that book! :)

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