WMC or Windows Memory Cleaner is a small free tool that I build to free memory on windows 10.
Are you familiar with the sentence long story short?
The short story is that I build a small tool – Windows Memory Cleaner, that as the name suggest clean Windows memory, you can download from the following link: WMC
There are 3 versions, 2 command-line tools, and one with UI, see the below image.
Windows Memory Cleaner The long story
The long story started several years ago when I was visiting customers as part of my working routine. In one of them, I was introduced to a tool that was able to do all kinds of stuff. One of the stuff it was doing was cleaning process memory. This retriggers my curiosity. I remembered that I had a tool that was only doing that on my home PC. I was thinking that I need to know how it is working.
One of the things that I accepted, when working with Windows OS, is that you need to restart the system from time to time to help it clean up. Especially when opening more than several tabs in a web browser, I think it is related to the ajax that working behind the scene updated with new data he pages that cause the system to eat memory and probably not release it as needed, but I am not sure as I did not investigate it.
I give it a short search but did not find something that can help me do it. Life was happening so I let it go and continue with the routine. Several weeks back, while struggling to move from one window to another on my PC, living me no other choice but to reboot the system, with lots of not saved files, lucky me that notepad++ save the files data even if you do not save it, there was no loss of data from my side.
The idea of cleaning the memory came back into my head and I started to search for a way to do it. Using C/C++ I need to say. During my searching I found all kinds of might work scenarios that if I will code them might do the job, but how can I be sure that I can free this heap? Let dig into it.
Then I found, a function that can do it, apparently there is a built-in function that can do it.
The technical warning starts here……
The function EmptyWorkingSet gets a handle to the process and tries to, according to the Microsoft docs – Remove as many pages as possible from the working set of the specified process.
I am not sure how to explain it, but once I found this, I had this strange feeling that everything is possible! I open my IDE and use this function to see if this is what I am looking for, and it works!
The magic happened and I was able to free memory from a running process, next step was to build a small tool that will run on all the processes and clean memory from them, using the brute force method I use a for loop to try and open each one of the running processes, and send the process handle to the EmptyWorkingSet function, and it works I was able to free memory from the running process.
The next step was to build a small GUI tool that will run and clean the memory. With an option to clean it once the system memory goes above some percentage. Letting the option for the user to set it up. Now I have a Windows Memory Cleaner tool that I run on my system to free memory from running processes. Oh, and it is completely free and without any warranty so use it at your own risk!
The next step was to buy a domain and hosting. Installing WordPress with some plugins that I like to use on my websites. Create a page with the needed information, tool screen, and links to download the tool. The site is ready, and everyone who wants can download the tool from the following link: WMC
The tool source code, for both of the versions, GUI and CLI, can be found on my GitHub under WMC
I would love to hear from others that familiar with this function or windows memory. Want to know how safe this function is from causing a process crash or other memory/data issues.
Hope you enjoy it. Till next time.
I am using the wmccli64 on a daily basis…running it every time I feel that the system starts to work slow…
Some legal stuff: The software is provided “AS IS” without any warranty, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The author will not be liable for any special, incidental, consequential, or indirect damages due to loss of data or any other reason.