CleanMem experimentation

Trying this program in a Virtualbox VM (no guest additions, 1 GB RAM) right now.

It can basically do two things (aside from monitoring): "Clean memory" and "Clean file cache."

The second is obvious enough, probably the rough equivalent of Linux's vm.drop_caches. That might improve performance, maybe, if Windows likes to swap out program memory to keep the filesystem cache big.

(Note that a) I don't believe that is the default setting for desktop versions of Windows, and b) Linux is aggressive about maintaining large FS cache sizes, and that only causes bad performance on systems with < 1 GB of RAM in my experience.)

The first though, I have no idea what on Earth it might be doing. It can't be that deep - the program is written in Visual Basic, I don't think it can even use the Native API! - but according to the task manager, whatever it's doing frees up a little memory... somehow.

As for performance, I can't tell if it makes any difference at all.

Next up, testing on a real laptop, and maybe some tracing with GDB.

Edit: I'm a fool! Sysinternals Procmon should be able to show me what it's doing. Gimme a minute.

One of the things I have verified, it fixes memory leaking programs. A few games I play/played had versions that exploded on themselves with memory leaks. Most recently World of Warplanes, everyone would crash after 30-60 minutes running the game. CleanMem kept me paying for hours.

I know Shane personally. Let me ask him if he minds commenting on this thread, and other places where we discuss his stuff. We've worked together on some projects.

One of the things I have verified, it fixes memory leaking programs. A few games I play/played had versions that exploded on themselves with memory leaks. Most recently World of Warplanes, everyone would crash after 30-60 minutes running the game. CleanMem kept me paying for hours.

I know Shane personally. Let me ask him if he minds commenting on this thread, and other places where we discuss his stuff. We've worked together on some projects.

Shane's net is down today, so he can't respond. But he said it's in use on 'millions' of computers... He said despite this, some people still bash it, and they usually are ones that haven't tried it.

Essentially CleanMem triggers windows to be more proactive in memory management using Windows API itself. That's why it works, and doesn't cause crashes.

So how does CleanMem work?
CleanMem Works by calling a Windows API. CleanMem doesn't change the working set of a processes. It simply asks Windows to do all the work. So Windows does the trimming, the moving and manages everything. This is why there is never any crashes of programs and any performance hit to the system. To put it short CleanMem doesn't work against the Windows memory manager, it works with it

But I have question that I tried to find the answer, which are all the "pro" functions exactly that will stop working after 7 days, is there a list somewhere showing
all the "pro" functions in the program?

The only answer I found about it was that some settings to the mini monitor is connected to the pro, but there must be more right?

Dig through here:
http://www.pcwintech.com/cleanmem-help
But no details on the remote admin/viewer.
http://www.pcwintech.com/cleanmem-change-log
Some info on remote admin. Seems like remote viewer is in free.

And it's buried in the readme file; I'll paste 'em up for those who haven't installed it:

•With v2.4.0
You can now view the memory and stats from the mini monitor remotely. You can also run CleanMem from the remote viewer.
•Pro version introduced with v2.0.0:
Advanced Monitor Rules: (The user can set these rules for any process they like (Not on protected processes of course)).
Clean the memory on a specific process when it hits a user set memory level. (Example: Firefox hits 150MB) The mini monitor cleans the memory instead of calling CleanMem. One less program to run
Kill a program if it hits a certain amount of memory.
Auto set process priority on a process.
Auto clean the system file cache when it reaches a set size.
Set how often the advanced monitor rules will run.
Auto run CleanMem when system hits a user specified % of memory used.
Great details on running processes.
Allow users to choose a picture (jpg, bmp, gif) for the mini monitor bar.
Allow user to choose what text shows on the mini monitor Example: Total memory, used memory, free memory, page file commit, file cache size, system uptime and more.
Show current file cache info.
Show extended memory usage stats.

I bought a couple of licenses about three years ago and those enhancements are sweet. Never used the remote admin, tho.

Shane's net is down today, so he can't respond. But he said it's in use on 'millions' of computers... He said despite this, some people still bash it, and they usually are ones that haven't tried it.

Click to expand...

Which is why I'm trying it.

Essentially CleanMem triggers windows to be more proactive in memory management using Windows API itself. That's why it works, and doesn't cause crashes.

Click to expand...

Like I said, if that actually works it indicates problems with Windows memory management - at least with how it's configured by default. That's not necessarily an indightment of CleanMem, or of Windows...

So how does CleanMem work?
CleanMem Works by calling a Windows API. CleanMem doesn't change the working set of a processes. It simply asks Windows to do all the work. So Windows does the trimming, the moving and manages everything. This is why there is never any crashes of programs and any performance hit to the system. To put it short CleanMem doesn't work against the Windows memory manager, it works with it

Click to expand...

That on the other hand tells me almost nothing, since it doesn't mention which API calls are used.

Which is why I've attached a Procmon log file to this post, in CSV format. Rename it from .txt to .csv and load it into Procmon and it will show a record of CleanMem's API call activities.

What does it show, for perhaps a minute of activity following a triggering of the CleanMem executable? From what I can see
- Several reads/writes to registry keys, some of which look related to memory management
- Some reads/writes to keys that look related to UI language stuff, not sure why (maybe VB stuff?)
- Temporary files creation, no idea why.
- Mapping of lots of Windows DLLs, including some crypto related ones. I'll give it the benefit of the doubt for now, and assume this is VB6 being overengineered.

So, it seems to do what says, sort of, I guess. And maybe some other stuff. As for performance improvements, I'm typing this in a 1 GB Windows 7 VM with CleanMem running, and it's slow as molasses, but that seems to be the normal state of affairs for Windows on every machine ever these days, never mind on underpowered VMs... Anyway, I can't see any benefit. Maybe you can, or maybe it's placebo, or maybe it's hinky Virtualbox memory management issues interfering with it. In any case, I would invite people who are better versed in Windows internals than myself to look over the Procmon logs.

Oh, one last note -

Mayahana said:

One of the things I have verified, it fixes memory leaking programs. A few games I play/played had versions that exploded on themselves with memory leaks. Most recently World of Warplanes, everyone would crash after 30-60 minutes running the game. CleanMem kept me paying for hours.

Click to expand...

Not sure how that would work, except insofar as it just makes more system memory available that would normally be used for file cache or whatever. If a program malloc()s stuff, and then doesn't free() it, there is not much the OS can do about it. There's no way to know for sure that the allocated memory is not still being used for something.

Attached Files:

I've been using the pro version for a few years now...After reading on many tech websites that memory optimisers were snake oil and usually inhibit performance rather than enhance it, on several occasions the authors suggested CleanMem was an exception that did improve machines with lower ram.

Much emphasis is made of the MiniMonitor at PcWinTech and for good reason.

But the CleanMem executable by itself is a powerful tool that can target specific goals for research or just convenience. It can be run on-demand or enabled in Windows Task Scheduler.

CleanMem.exe is governed by the CleanMem.ini file. The ini file is built with CleanMem_Settings.exe, the CleanMem Settings Wizard.

Steps 1 & 2... intuitive.

What happens between steps 3 & 4 depends on what is selected in 3. The pane for Ignore (shown) or Only will present prior to 4. When all Processes is selected, it goes directly to 4.

The items for manipulating a Task Schedule in 4 can be ignored.

Finish escapes the Wizard and the CleanMem.ini is written.

Different ini files can be built by renaming the CleanMem.ini file before building another. In this way you can create several ini files and by copying the one you want to use and renaming it to CleanMem.ini you can build a purposed library of ini files. The files are quite simple and with a text editor you can become the CleanMem Settings Wizard.

When CleanMem.exe is run, there is no visual indication of the process. I watch it in Task Manager; it's usually over in a few seconds. If scheduled, you'll need to reference the log files or Task Scheduler's "Last Run Time."

I too am a strong believer in letting Windows manage memory as it wishes. And the less memory you have or the greater the workload the more important this becomes.

Cleanmem creates available memory and this would seem a good thing. But the improvement is only cosmetic with no gains in performance. Microsoft could have included something like it in the OS if they wished. But they didn’t because the OS already has something better. Windows is fully capable of reducing the working set of a process if this is necessary or deemed desirable. And it in fact does this as a routine matter. But unlike the brutal approach of Cleanmem it can do this by as large or small amount as the situation warrants. And the memory manager has access to a great deal of data that allows it to make a more intelligent decision as to what process should be trimmed and by how much. Cleanmem has no access to this information.

Incidentally, processes do not allocate or free RAM. They allocate from their own virtual address space. How much RAM as mapped to RAM is under the control of the memory manager. It is the memory manager that controls how much RAM a process is using. Processes themselves have limited influence over this and it is rarely used.

In most situations Cleanmem will negatively impact performance, but usually not enough to notice. The only benefit is to make the numbers in Task Manager more attractive to people who do not really understand them.

The working set of a process is the amount of memory physically mapped to its process context. PSAPI enables you to take snapshots of the working set or to monitor the working set.

Click to expand...

IOW, it sounds (might be wrong here) like it is unmapping as much process memory as possible. IOW, if there are pages not being used, it lets them vanish from RAM. They don't need to be forced to swap because they are already present on the disk, in the program's executable file.

If that's the case though, the downside is that they will have to be read back to RAM later if the program does wind up using them.

So, if I'm correct about this, the upshot is that it's like a "memory nice" command. It will reduce the memory consumption of target programs, slowing them down in the process, but making the rest of the system faster. Like a memory version of Linux's "nice" command.

It probably won't help with malloc() related memory leaks, but that's a whole other matter...

Shane - if you're reading this, and it's actually accurate, then I would humbly suggest an improvement... A way of making sure CleanMem runs only against specific memory hungry processes, rather than every user process. I suspect it would be more useful for reigning in certain applications (Firefox, Chrome, memory hogs that don't need high priority).

Microsoft engineers never read details, so they will just say, Superfetch is supposed to take RAM and that is it. They do not care, that there are other bugs, like app, that requires only 20MB for an example, takes more and more RAM over time, until it reaches a few GB and results in crash, because it never release unused RAM.

So if someone has memory problems, which can not be solved by increasing a pagefile, he can: 1. install Cleanmem or 2. buy more RAM. That is self-explanatory.

Process Lasso is definitely a great program and always in development. I've purchased a lifetime license over two years ago. There was a memory trimmer in the app called Virtual Trim in which you can periodically set a timer to purged the virtual memory but it reallocates. This new mechanism will essentially determine programs that are persistent RAM hoggers and act accordingly but ignore other programs that aren't. You can do this in Cleanmem via excluding programs as well

I have used this on older machines with much improvement, but I prefer to use it with MiniMonitor rather than (EDIT: the optional) Task Scheduler.

Click to expand...

My oh my... This by far exceeds my every expectation for the work I put into my #10 post here. Especially since MiniMonitor is a completely different tool. No matter, what you prefer is so very special and truly an incredibly significant contribution to this thread!

If I'm reading the API documentation correctly though (and I think I am now), it still doesn't have the intended effect. Since it's freeing clean pages from all applications, not just selected ones, it will just slow down programs that need to read stuff from the disk again later. That may be zero programs, or it may be most of them, depending on your workload.

If you omit some application from its list, then you're basically letting that application put more of itself in RAM. That may be useful, or it may not.

Point is, it might work sometimes (or not) but it's still a hack and I wouldn't rely on it. As a more targetted tool for dealing with individual hogs, I think it might be more useful, but still more of a developer tool than an end-user performance improvement...

Edit: on a purely anecdotal note, I tried it on a spare laptop, and didn't notice any performance improvement there either.

Maybe it makes most sense to add more memory? Even the developer advocates this approach.

CleanMem doesn't work magic on your system. The best thing you could do is get more memory for your system! The goal of CleanMem is to help keep windows from needing to rely heavily on the page file. Which is located on your hard drive.

Click to expand...

You will NOT notice a night & day performance increase. The users who get the best performance out of CleanMem are the users who don't have a lot of memory. I know others would yell at them and say "well just buy more memory!" Well not everyone can run out and buy memory. CleanMem will help them until they do.

My oh my... This by far exceeds my every expectation for the work I put into my #10 post here. Especially since MiniMonitor is a completely different tool. No matter, what you prefer is so very special and truly an incredibly significant contribution to this thread!

Click to expand...

MiniMonitor calls CleanMem instead of Task Scheduler, so in effect, it is not a completely different tool.