CleanMem experimentation

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

  1. roger_m

    roger_m Registered Member

    Joined:
    Jan 25, 2009
    Posts:
    8,120
    I certainly does, but in some cases that is not possible. For example, the laptop I'm using right now only has a 32 bit CPU which limits be to using 32 bit versions of Windows which can only use a maximum of 3GB of RAM. Also, as I posted in another thread, I encountered a laptop which had the 2GB of RAM soldered to the motherboard, preventing it from being upgraded.
     
  2. Mayahana

    Mayahana Banned

    Joined:
    Sep 13, 2014
    Posts:
    2,220
    I have between 8Gb to 16Gb on every system. I still like CleanMem as it keeps unruly things in order. As noted, I've used it to keep memory leaking games from crashing. Hence, it's sort of an automatic install for me on home machines here.

    8Gb isn't even used, even on aggressive games. 16Gb is pretty overkill. Does any game use anywhere near 8Gb? Even Thief maxed out at 2K resolution uses only 2Gb of ram.
     
  3. Gullible Jones

    Gullible Jones Registered Member

    Joined:
    May 16, 2013
    Posts:
    1,466
    @wat0114, that generally goes without saying.

    Re software stuff, disabling Superfetch might, maybe, sometimes make a difference depending on the machine. I think the common denominator there might be 5200 RPM laptop hard disks - trying to aggressively expand the filesystem cache might not be so smart, if you're trying to do other stuff on a slow hard disk at the same time. But I don't have enough data to confirm that. And anyway this performance stuff tends to be kind of situational...

    e.g.

    http://don.blogs.smugmug.com/2008/05/01/mysql-and-the-linux-swap-problem/

    This guy solved some nasty MySQL performance problems by putting swap on a RAM disk. For a desktop that would be ineffective and probably dangerous, but a MySQL server is not a desktop! From what he says (but do note, I'm not a DBA) the Linux memory manager is by default tuned very badly for certain database workloads; letting it swap to a fake swap device in RAM, instead of aggressively swapping to disk, in this case alleviates the problem.

    (And keep in mind, again, that that's a hack. The real problem is the kernel's behavior.)
     
  4. J_L

    J_L Registered Member

    Joined:
    Nov 6, 2009
    Posts:
    8,738
    For my 16 GB, I allocate 8 GB to a RAM disk and 4 GB to each virtual machine. Don't use multiple VM's at once, so that works out pretty nicely.
     
  5. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    From https://www.wilderssecurity.com/thr...s-a-load-of-old-cobblers.221793/#post-1326343:
    From Why Memory Optimizers and RAM Boosters Are Worse Than Useless:
     
  6. Gullible Jones

    Gullible Jones Registered Member

    Joined:
    May 16, 2013
    Posts:
    1,466
    @MrBrian: I missed Russinovich mentioning EmptyWorkingSet. Anyway I'll assume he knows what he's talking about better than I do.

    On Linux BTW the equivalent of this would be vm.drop_caches=1, which drops clean pages from memory for all running programs. Doing that will slow things down visibly and immediately.

    (Not sure if the analogy extends to Linux though, as Linux is a simpler OS in a lot of ways. e.g. as far as I know, Linux kernel memory can never be paged out to swap space.)
     
  7. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    On a limited skimming of some of the mentioned links, I believe that EmptyWorkingSet is useful in relatively disadvantaging the performance of those processes that it's used on. However, if EmptyWorkingSet is used for every process, then I don't see the benefit. It's kind of like insisting that everyone can be above average (or below average).

    Here are some other long discussions of CleanMem:
    http://forum.piriform.com/index.php?showtopic=28918 (developer participated in this one)
    http://forum.step-project.com/topic/2121-caution-about-memory-optimisers/
     
    Last edited: Dec 28, 2014
  8. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    From Mark Russinovich in the link in post #22:
     
  9. J_L

    J_L Registered Member

    Joined:
    Nov 6, 2009
    Posts:
    8,738
    How-To-Geek claiming what the source document doesn't state and was completely lacking in details. Russinovich didn't seem to mention EmptyWorkingSet.

    Honestly, all the detractors appear either misguided, dishonest, or ignorant of CleanMem. I've yet to see real evidence that it doesn't do it's job. Although there may not be a noticeable difference, the performance won't decrease.
     
  10. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    See 1:01:50-1:05:30 of http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/WCL406.
     
  11. Gullible Jones

    Gullible Jones Registered Member

    Joined:
    May 16, 2013
    Posts:
    1,466
    This, exactly! Using it on every process is like giving your user a default niceness of 5 on Linux, and expecting that to usually help performance.
     
  12. J_L

    J_L Registered Member

    Joined:
    Nov 6, 2009
    Posts:
    8,738
  13. majoMo

    majoMo Registered Member

    Joined:
    Aug 31, 2007
    Posts:
    993
     
  14. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    Some background info in this post.

    From Design: Memory working set explored:
    More on this from one of the Windows Internals books can be found at https://books.google.com/books?id=CdxMRjJksScC&pg=PT623#v=onepage&q&f=false.
     
  15. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    Maybe of interest given the topic. I don't know if this should be posted to a Wilders AVG thread also.

    From a thread about AVG 2012 Free Edition:
     
  16. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    It's interesting to test memory using Sysinternals TestLimit (download at hxxp://download.sysinternals.com/files/TestLimit.zip). For example, on a 64-bit system, run this command to allocate and write to 1000 MB (= 1 GB) of virtual memory (caution: close any important unsaved data before running this, in case there isn't enough virtual memory available):

    testlimit64.exe -d -c 1000

    Then use Task Manager, Resource Monitor, RAMMap, and VMMap to look at the various memory-related numbers for testlimit64.exe. You might need to use a number bigger than 1000 to notice differences between testlimit64.exe's use of virtual and physical memory.

    VMMap has an "Empty Working Set" command that I suppose does the same thing as CleanMem, except that VMMap does it for one process at a time.
     
  17. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    Here are the testlimit64.exe numbers that I got a few minutes after running command testlimit64.exe -d -c 1000 on a Windows 7 x64 virtual machine with 1 GB of physical RAM:

    VMMap:
    Private Bytes=1,027,536 K
    Working Set=115,320 K

    Resource Monitor:
    Commit (KB)=1,027,536
    Working Set (KB)=115,320
    Shareable (KB)=420
    Private (KB)=114,900

    Task Manager:
    Memory (Private Working Set)=114,900 K

    RAMMap:
    Private=113,036 K
    Standby=230,944 K
    Modified=369,480 K
    Page Table=2,136 K
    Total=715,596 K

    Notice that the default memory number reported by Task Manager (114,900 K) is far lower than the virtual memory used (1,027,536 K).

    Most of the above numbers also change over time, showing that Windows is dynamically managing memory.
     
  18. XhenEd

    XhenEd Registered Member

    Joined:
    Mar 31, 2014
    Posts:
    536
    Location:
    Philippines
  19. stapp

    stapp Global Moderator

    Joined:
    Jan 12, 2006
    Posts:
    18,030
    Location:
    UK
  20. XhenEd

    XhenEd Registered Member

    Joined:
    Mar 31, 2014
    Posts:
    536
    Location:
    Philippines
  21. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    One of the Windows Internals books has a diagram and explanation of memory page dynamics.

    From the above, we can infer that when EmptyWorkingSet is called, pages from the working set are put in either the standby page lists or the modified page list, but not the free page list.

    Here are some incorrect statements:

    From Why Memory Optimizers and RAM Boosters Are Worse Than Useless:
    That's not correct because from the diagram we can see that it's also possible that pages from the standby page lists and modified page list can be "soft page faulted" back into the working set.

    From CleanMem developer Shane here:
    That's an incorrect statement because we can see from the diagram that it's possible that pages in the modified list can be written to the disk's pagefile by the modified page writer.

    Disclaimer: I'm not a memory management expert; I'm just trying to understand this stuff. Corrections are welcome.
     
  22. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    My current view is that I'm open to the possibility that CleanMem-type programs could be useful. I haven't personally tried CleanMem.
     
  23. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    Some interesting info from Reducing runtime memory in Windows 8:
     
  24. MrBrian

    MrBrian Registered Member

    Joined:
    Feb 24, 2008
    Posts:
    6,032
    Location:
    USA
    I've come to the conclusion that CleanMem-type programs might indeed be useful in certain situations, such as dealing with programs that leak a lot of memory or do a lot of one-time memory allocations. Whether one is better off with or without CleanMem (or similar) is an empirical question that I haven't delved into, and might be different for different systems, workloads, etc. It might be better to target just likely-problematic processes than all processes. If you're interested in testing, you can test using VMMap's "Empty Working Set" command, along with the programs mentioned in posts #41-42.
     
  25. SMC1979

    SMC1979 Registered Member

    Joined:
    Jan 2, 2011
    Posts:
    13
    Wow. It is hard to believe that after all these years people are still talking about my CleanMem. I am honored :)

    But I do notice some confusion about it and such, so I think the best way is to give a little back ground to it and how I came to make CleanMem and a little more info.

    First off CleanMem doesn't replace or do anything to the Windows memory management. It is nothing more than the trigger to make Windows do its job.

    As a programmer, if you look at anything about programming it is the programmers job to make sure the program cleans up after itself, not the OS's job. So this is why Windows doesn't normally step in until memory and resources are almost used up.

    It is easy for a programmer to miss something simple and end up having a memory leak in their program. A simple example is creating a pen to do some drawing or text
    http://msdn.microsoft.com/en-us/library/windows/desktop/dd183509(v=vs.85).aspx

    When they create it they must delete it when they are done, otherwise it stays in memory. And so memory will climb every time a new pen is created. Even Windows has had multiple of its own programs and services with a memory leak. Most likely because there is a minimum of 10,000+ programmers that are used when making a new version of Windows, for Windows 7 there was 110 programmers just for the start menu and task bar alone!

    With that many fingers in the pie you are bound to have some messy problems.

    Well MS started to see that this wasn't good enough to rely solely on the programmer to cleanup memory. So starting in .Net they added a auto garbage cleanup in it. I noticed it when i first tried .net and when ever you minimized a .net program the memory got cleaned up. This was MS's way of trying to help keep the memory clean in a more of a automatic way since so many programs where not doing it properly.

    I noticed this and thought this was great, but is there a way I can use it in my VB6 programs. So I started digging in what the .net programs where doing and that is when I found the emptyworkingset api. I found it was the api being used for it, so I tried it in my own vb6 programs and it worked great. So I then made CleanMem, which I only put on my customers computers who where using AutoCAD and others with only 1 GB of ram and sure enough it kept AutoCAD from crashing. (These where old machines and this was about 7 or 8 years ago)

    So once I started PcWinTech I needed some programs for it and so put CleanMem out. And holy crap the firestorm that started! People where bashing it before they ever tried it. Because they thought right off the bat it was doing the same trick the other programs were doing, where they simply fill up the unused memory, forcing windows to start cleaning up the memory of the other programs, which pushed almost all of it to the page file, making things much worse.

    Windows started getting better at memory management, but depending on the program you can still have some troublesome problems. One example was a game I was installing that used an installer that worked fine on XP. The game was about 8 GB in size and when installing on XP memory never moved much while it was installing. Then when I tried to install it on a Windows 7 machine I noticed the memory climbed and climbed till it was completely full and the installer would finally fail and crash. Even after the installer was closed the memory was never cleaned up. I looked at the resource manager and found that the modified memory section had filled up the entire thing! A reboot was the only was to clear it.

    Turns out it was the way the installer was marking the memory that made Windows 7 treat it as modified and to not touch it till it was cleared by the program itself.

    So how does my CleanMem help at all?

    First off it will normally never make a program any faster what so ever. There have been a few programs that it did help make faster, but those where programs that had bad memory leaks. On other programs it doesn't make a difference.
    The help comes from not needing to use the page file, which is ran off the hard drive and the hard drive is the bottle neck of performance. You can transfer GB per sec in memory but only 10 to 50 MB per sec on the hard drive depending on the load. (SSD has made this much better, but still not even close to the speed of memory)

    I had users who had horrible hard drive thrashing because of the page file that went away after using CleanMem, these where the ones who felt a total system improvement.

    I have 12 GB of memory in my system and yes I still use my CleanMem. Memory is fast and you want to use it as much as possible. But I want it used with stuff that is needed, not trash. Just because I have a 1 TB hard drive doesn't mean I want it filled with junk files. I treat memory the same way. In fact on my system I enable all the tweaks and such to make Windows force as much into memory as possible. When CleanMem runs when playing a heavy 3d game on ultra settings the game doesn't even miss a beat.

    On some test after CleanMem ran Windows freed up about 400 MB of memory and about 20 MB of it was pushed to the page file (These kinds of test are all dependent on the programs that are running of course). This is what Windows decided to do with it, not CleanMem. Again CleanMem is simply the trigger.

    So for me I treat my memory like I do my drives I like them clean and used for proper stuff. I don't want a memory leaking program using up all the memory, just like I dont want temp files or junk files filling my drive.

    So why use CleanMem instead of just letting Windows handle it?
    Because of what I said before, Windows doesn't feel it is its job to clean up after a program. In every text book, every teacher about programming will tell you, clean up after yourself! But MS started to see that this simply wasn't happening. Started making auto cleanup tools in their newer .nets and started making Windows handle the memory better. But Windows still doesn't always do the best job, and like anything there is always a program or situation that might be different that you have to change your game plan on.

    Here is a perfect example of a user who did some digging and found the proper setup of how to use CleanMem for his setup. It is worth a read.
    http://forums.pcwintech.com/index.php/topic,5403.0.html

    I am not here to fight with anyone, anyway, shape or form. You use CleanMem and like it and it helps you, great! You dont use CleanMem and dont want to? Totally fine as well! CleanMem goes on every system I work on and I have never had a problem with it, a few years back I got an email from an admin that CleanMem was put on over 2,000 servers for the polish government because their old tax software had horrible memory leaks and CleanMem kept it from crashing. That put a big smile on my face.

    Will CleanMem work for you? Perhaps. Depends on the programs you have running, any memory leaks? Heavy page file usage? Or are you just a performance freak like me and just want to keep things clean like you do everything else? Then CleanMem can help. Dont have any of those problems? Then you wont see any difference at all with CleanMem. But like even on my system, I still have it run via the task scheduler, just for those times I see Windows update taking 1 GB of ram for some retarded reason lol

    But please remember, CleanMem isnt worth fighting over. It is a small simple program and isnt meant to start a firestorm about memory cleaners. CleanMem isnt a normal memory cleaner that fills the memory to force Windows to work. It is simply a trigger to Windows to do its job without having to use that old horrible way of getting it to go.

    So, I will not debate with anyone on this, I have before so many times that I simply don't care any more lol. I don't say that in a angry way, but in a tired way of seeing how many times that no matter what you say you are not going to change someone's point of view once they are set on it. So why do that? The best answer is this, Try CleanMem, if it doesn't work then get rid of it, it does work, then you just got another little tool to add to your toolbox :)

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