CleanMem experimentation

Discussion in 'other software & services' started by Gullible Jones, Dec 26, 2014.

  1. clubhouse1

    clubhouse1 Registered Member

    Joined:
    Sep 26, 2013
    Posts:
    1,124
    Location:
    UK
    Informative interesting read Shane...I'm no techy who understands all the babble tech speak that the "experts" use here, but you made that easy to understand and thank you for convincing me despite the nay-sayers that CleanMem does serve a purpose on any system :)
     
  2. Mayahana

    Mayahana Banned

    Joined:
    Sep 13, 2014
    Posts:
    2,220
    Thanks for stopping by buddy!

    Funny thing, World of Tanks had a hideous memory leak that lasted for months. I found I NEVER had the crash, but people not running CleanMem crashed every 10-15 minutes, rarely lasting over 20-30 depending on ram. Clearly a memory leak, and it took them months to fix it. I think after I posted on the forums about CleanMem fixing it you probably had a million or two downloads of it because something like 34million play WOT. So as a matter of practice, I install it quite often.
     
  3. rdsu

    rdsu Registered Member

    Joined:
    Jun 28, 2003
    Posts:
    4,537
    @SMC1979 ,

    Thanks a lot for you program!!!

    I already use it for about 4 or 5 years, and my system always felt more stable and fast...
     
  4. Gullible Jones

    Gullible Jones Registered Member

    Joined:
    May 16, 2013
    Posts:
    1,466
    @SMC1979 I think we're talking past each other here... I think.

    To everyone reading this, I'll try to get this across simply... If I can't, that reflects worse on me than on you.

    Windows manages paging. Memory is divided up into 4 kilobyte chunks, which can either stay in RAM (real memory) or remain on the disk. The ones on the disk will be either stored in their executable file, or they will be stored in the pagefile; the latter is only if they have been modified while in RAM. All of these - RAM, files, and pagefile - count as part of virtual memory. Generally, the more of a program is in RAM, the more responsive the program will be.

    Windows manages paging entirely by itself. It may take cues from applications (like CleanMem) but it's the kernel, the core of the OS, that does this.

    Individual applications don't manage paging. Ever. They can't, because it's a hardware function that the kernel controls exclusively. What they manage is allocation.

    In C, which is the de facto standard programming language for pretty much every operating system, there are functions named malloc() and free(); or something similar in the case of the Windows API (which has different function naming conventions than the C standard library). malloc() allocates a chunk of virtual memory. Once it is allocated, it is never ever released until that program either calls free() on it or exits.

    This is the part where programs manage their own memory. They have to, because the kernel cannot just make an application free its allocated memory chunks. There is no way for the kernel to know that, hey, this program is still using this chunk of memory that's about to be freed up, and might crash when its data suddenly is put up for grabs by other applications! Only the program doing the allocation can run free() and deallocate that memory when it's done using it.

    (And note that there is an entire class of bugs based on deallocating too early, known as use after free bugs. If a program uses memory that has had free() called on it earlier, all kinds of weird things happen, including exploitable vulnerabilities.)

    And here's where the two kinds of memory management intersect:

    If you tell a program to dump the stuff it has in RAM, it will do that. But it will not get rid of virtual memory, in executables or the pagefile, that it has allocated. And if it is leaking memory - i.e. calling malloc() without a subsequent free() - then its virtual memory usage will expand. And expand. And expand. You may forestall an out-of-memory crash by forcing more and more of it back onto the disk, so that it's not competing for RAM with other programs; but it will get slower and slower, and the crash will happen eventually. Tools like MemClean may be able to keep a badly written program running, but they do not fix the root cause of the memory leak, which is failure to manage allocation, not failure to manage paging.

    This is why I object to the statement that CleanMem "fixes" memory leaks. It doesn't fix them, it forestalls their immediate effects. It might work, but only for a while. And I do think it's important to differentiate between those things, at least if you're an IT professional; because if you don't, it might come back to bite you when working on computers (or VMs) with very high uptime.

    Hope that makes my position clearer...
     
  5. SMC1979

    SMC1979 Registered Member

    Joined:
    Jan 2, 2011
    Posts:
    17
    And you are correct. CleanMem can only do what Windows does with that API. Virtual memory is never touched and never shrinks, because, well like you said, the API doesn't touch it. It only handles the working set memory, nothing more. This is why when the modified memory got maxed out on the game install cleanmem didnt help at all.

    There are also different kind of memory leaks though as well, since as you pointed out there is different ways the memory is mapped. I have had programs leak memory purely into the page file and no where else, I have seen others where like you said the virtual memory grows and then I have seen a lot of them grow the working set very large. In C which I only spent a little time in you have MUCH MUCH more control to what you can do with the OS. In VB and others it goes through runtime files where to do some of the advanced stuff that I do I go through API calls to the OS. Here it is far easier to have a working memory set leak. I also have to look at GUI objects as those can leak as well and make the system run out of resources, even when there is still memory available.

    There are so many ways to have a program leak and not clean it self that it was always surprising MS never offered a garbage cleanup. I guess thats why they finally did it in .Net.

    But just like in my new Technicians Toolbox I have out in beta on my tweaking.com site I have all the code cleaned up to keep memory from growing and growing on it, but the GUI objects keep climbing. I traced it down to not the code in my program but instead an API call to Windows to their balloon tool tip text. Every time that API is called the gui count would grow and not go back down. Found no way to call an API to clean it up, turns out it is a bug in the API and depends what version of Windows you are on, so for now I removed the balloon tips.

    It is things like these that make it easy for any program to have some sort of small leak and not be able to clean itself up properly. When I create a pen or brush and a few other things I can call the deleteobject api call to remove it once I am done and free that memory, if I dont it tays in memory just as you described. But other API calls dont have a delete or cleanup option, so you are stuck with how Windows handles it.

    Think it is safe to say that Windows still has flaws after 25+ years lol

    But again it really does come down to the program in question and how it is leaking, if at all and how it was written. I have had CleanMem make a big difference on a LOT of programs, and no difference at all on others.

    -Shane
     
  6. roger_m

    roger_m Registered Member

    Joined:
    Jan 25, 2009
    Posts:
    8,627
    @SMC1979 thanks for your informative posts Shane. I might just install CleanMem on my current laptop as it has only 3GB of RAM of to run Windows 10.
     
  7. Mayahana

    Mayahana Banned

    Joined:
    Sep 13, 2014
    Posts:
    2,220
    FYI:

    Norton 2015 users, you need to add programfiles\cleanmem to exclusions.
    Also add windows\sysWOW64\cleanmem.exe to exclusions.

    Otherwise Norton will prevent it from doing anything, and you can check the logs to verify.
     
  8. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    I agree with the above. CleanMem doesn't change the committed virtual memory of a targeted process. So logically, if a targeted process eventually has fewer memory pages in physical RAM as a result of a call to EmptyWorkingSet, anyone want to guess where it must have gone? (Hint: see post #46 or #54.)

    For the record, there are other memory optimizer programs that call EmptyWorkingSet. One example is Minimem, according to http://processhacker.sourceforge.net/forums/viewtopic.php?t=172.

    @SMC1979: Thanks for participating :).
     
  9. clubhouse1

    clubhouse1 Registered Member

    Joined:
    Sep 26, 2013
    Posts:
    1,124
    Location:
    UK
    I still find Shane's explanation of MemCleans advantages more compelling than any other posts I've read here...Been using the pro version for 6 months now, it stays.
     
  10. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    Last edited: Dec 29, 2014
  11. SMC1979

    SMC1979 Registered Member

    Joined:
    Jan 2, 2011
    Posts:
    17
  12. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    It will be moved to the standby list if the memory page already exists in the pagefile and it was unaltered in physical memory. It will be moved to the modified list otherwise. (Notice that the experiment is titled "Experiment: the modified and standby page lists.")
     
  13. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    From the book's text:
    We can see from the diagram at https://books.google.com/books?id=CdxMRjJksScC&pg=PT575#v=onepage&q&f=false that the transition from the modified list to the standby list involves the use of the modified page writer, which writes the modified page to the pagefile.
     
  14. SMC1979

    SMC1979 Registered Member

    Joined:
    Jan 2, 2011
    Posts:
    17
    Yes, but it all depends on the program that it is happening to. Not every program handles its memory the same way. Thats why in most of the tests you will see the memory free up and only a small portion of that gets moved the page file, such as the one I did where 400 mb where freed and only 20 mb went to the page file.

    But like I said in my first post, I have no desire to debate this. All I have to say is try it and test it out. I have never once seen it cause a slow down on any system. It either helps or it doesn't, but never seen it hurt or slow the system in any way. If it did why would there be so many people who notice a faster system (Keep in mind these are people on old machines with not a lot of ram)

    I dont have the knowledge to go that deep into the Windows kernel. Granted I understand what I am reading and can see why people point to those. But keep in mind that with each version of Windows the kernel changes and how memory is handle changes as well. MS gave this API out for a reason, that was .net and programmers who want to use it. So far the best thing I have to say is try it since all I know is the results that I have seen and personally used. I trust results better than I do info about windows, mainly because as a programmer half of what MS says is suppose to happen normally doesn't when it comes to the kernel and api lol.

    But please, I dont want to debate. Just try it, if it doesn't help you any then remove it, if it does then keep it. Thats all I ever intended with this program. Instead it was like walking into a fight over abortion or gun laws. *possibly offensive phrase removed* there is two sides lol

    My baby girl turns one tomorrow (My 5th and final child), I am days behind work and so pulling a late night to get caught up and need to go answer 40 forum posts on my two sites fix 4 computers by morning for customers and get some programming done. So I have to run, I was asked to drop in some info and so I thought it best to tell people how and why I came up with CleanMem and let people decided by the best way possible, testing.

    Night!

    Shane
     
    Last edited by a moderator: Dec 30, 2014
  15. SweX

    SweX Registered Member

    Joined:
    Apr 21, 2007
    Posts:
    6,429
    Thank you Shane, very informative posts indeed. :)
    Good luck with all that, and happy birthday to your baby girl :cool:
     
  16. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    I agree. The reason why is because after EmptyWorkingSet is called on a process, in some cases (hopefully many cases) the process' attempted access to memory can cause "soft page faults" to bring memory pages back from the standby lists and modified list (which are kept in physical memory) into the working set (which is also kept in physical memory). If the required memory page is no longer in physical memory though, then a "hard page fault" will be needed to get the memory page from the disk's pagefile, which involves a performance hit.
     
  17. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    FYI: RAMMap has a command called "Empty Working Sets". VMMap has a command called "Empty Working Set" that can be used per process.

    From book Windows Sysinternals Administrator's Reference:
     
    Last edited: Dec 30, 2014
  18. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    That's true. I guess Mr. Russinovich perceives it as useful in some occasions, given that two of his programs have "Empty Working Set(s)" commands (see my last post.)
     
  19. IvoShoen

    IvoShoen Registered Member

    Joined:
    Jan 2, 2008
    Posts:
    849
    CleanMem is the ONLY memory cleaner that I trust and use. All others just slowed my computer down.
     
  20. musings4

    musings4 Registered Member

    Joined:
    Sep 24, 2013
    Posts:
    21
    As of late any Chromium-based browser blocks Cleanmem.exe from being downloaded, stating the program will affect the performance of the browser. I've downloaded the file from MajorGeeks.com.

    snapshot.jpg
     
  21. roger_m

    roger_m Registered Member

    Joined:
    Jan 25, 2009
    Posts:
    8,627
    Since installing CleanMem on my laptop running Windows 10 Technical Preview, there has been a noticable drop in RAM usage, so I'm keeping it installed.
     
  22. SMC1979

    SMC1979 Registered Member

    Joined:
    Jan 2, 2011
    Posts:
    17
    Chrome auto blocks any exe that doesn't have a digital cert. Nothing more, you can disable that in chrome or just use another browser. Since slimjet is based off of chrome, it does the same check. So basically any programmer that doesn't have a digital cert is punished lol

    Funny thing is, chrome doesnt check inside of zip files, it only does it when download exe files.
     
  23. Night_Raven

    Night_Raven Registered Member

    Joined:
    Apr 2, 2006
    Posts:
    388
    It's really interesting that so many people believe so easily and are convinced that some random guy knows more about the OS kernel, and more specifically the memory manager, which is the most complex component of the OS kernel, than the entire team of software engineers at Microsoft who have worked on it through the years. Yeap, seems legit.
     
  24. Mayahana

    Mayahana Banned

    Joined:
    Sep 13, 2014
    Posts:
    2,220
    If you knew people at Microsoft, you wouldn't find it hard to believe.
     
  25. roger_m

    roger_m Registered Member

    Joined:
    Jan 25, 2009
    Posts:
    8,627
    You should read all Shane's post before making such an ingorant comment. He is not claiming any of what you said. CleanMem is using a standard OS function - but doing it more reguarly than Windows does.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.