Memory Use (needs optimising)

Forum for MailWasher Pro 7 and/or older 2011/2012 versions.
BuBBy
Rattled Rabbit
Posts: 2
Joined: Wed May 19, 2010 9:18 pm

Memory Use (needs optimising)

Sat Jul 17, 2010 4:25 pm

Just noticed that MailwasherPro.exe uses more memory on my PC than a running instance of Firefox (140MB+) and when closing it to the notification area - it stays the same.

I realise it is still early days, and MWP has just come out of beta - but please can I put on the table that an upcoming (real soon) build we get the option to unload some resources when running in the background/standby/tray (whatever).

Alternatively - for the users who came from using 6.x - perhaps an alternate, less glitzy version that does the job without the bulk? At this moment MWP uses MORE memory than anything else on my system - including Defensewall Personal Firewall, Microsoft Security Essentials, AdMuncher, LinkMan, NetLimiter, Rainlendar, VLC Media Player - even Adobe Dreamweaver CS4 uses half as much memory as MWP. :rant

Thanks.
ru
rusticdog

Re: Memory Use (needs optimising)

Sat Jul 17, 2010 5:08 pm

A lot of this is due to the nature of Windows Presentation Foundation and .NET 3.5, but then also memory reported in Task Manager isn't much of an indication of what's really going on. It's common for more memory to be allocated than is actually used, and the CLR may not release that memory unless it's actually needed.

So have a lot of RAM spare and you'll find the 'reported' use to be quite high. If a machine is lower on memory then you see the memory cleanups occur more often.

That's not to say we aren't going to look at improving of course, but I think there is a Task Manager syndrome many people have left over from the bad old days when Windows wouldn't cleanup properly (98/Me) and when available RAM was more of a premium.

Cheers
User avatar
stan_qaz
Omniscient Kiwi
Location: Gilbert, Arizona
Posts: 8671
Joined: Fri Jul 25, 2008 5:13 am

Re: Memory Use (needs optimising)

Sat Jul 17, 2010 6:22 pm

Windows has been getting better at memory management but it still doesn't give the user all the information they really need to make decisions about a program's memory usage. There is some core part of an application that must be present, more bits that can be brought in as needed and discarded if memory gets low and a similar situation for data used by the program. It makes sense to keep as much program and data as possible in memory if there is room as that makes for a much faster program.

One of the usual first posts seen in Linux forums is a panicked query about memory being 90% or more in use while the system has 4 GB or more RAM. Once the speed/memory trade-off is explained things make more sense.

Another reason to keep data in memory is to allow the disk to go idle saving power. If you keep writing to it every couple minutes it stays at full power, if you save stuff in memory until space gets low the drive may not have to be spun up for hours on end. I have one Linux box running 24x7 that spins up the disk every 5 to 6 days for a few minutes.
ru
rusticdog

Re: Memory Use (needs optimising)

Sat Jul 17, 2010 6:31 pm

.NET also allocates 1MB per thread, my Idle MW has 21 threads, so that's 21MB allocated. I don't know if we could/should alter this, I'm inclined not to on instinct, would need to do a lot more research on that.
User avatar
stan_qaz
Omniscient Kiwi
Location: Gilbert, Arizona
Posts: 8671
Joined: Fri Jul 25, 2008 5:13 am

Re: Memory Use (needs optimising)

Sat Jul 17, 2010 6:44 pm

This is a helpful article on Windows memory use: http://www.itwriting.com/dotnetmem.php

Here is a snip:
If you search back through .NET discussion groups you’ll see many conversations like this. Newcomer to .NET says: “I’ve just been looking at Task Manager. Why does my simple VB.NET Windows application use 12MB RAM?” The answer comes back, “Don’t worry. The app doesn’t really use that much RAM; Windows will give it back if other apps need it. Minimize your application and you’ll see how little it really needs.” Newcomer minimizes the app, and sees the Mem Usage reported go down to say 750K. You don’t even need to minimize it: if you execute the API call SetProcessWorkingSetSize with -1,-1 arguments, then Windows will trim the working set immediately.

However, the point that needs emphasizing is that the minimized figure is just as misleading as Task Manager’s figure. Here’s my high-level understanding of how it works. What Task Manager reports is called the Working Set. This is the amount of physical RAM allocated to the process. To complicate matters, some of the memory in the Working Set may be shared with other processes, including parts of the .NET runtime. Therefore, there is double counting in Task Manager’s mem usage column. Windows may also allocate additional memory to the process in case it may be needed later. For these reasons, the Working Set may overstate the real memory requirements of the application.
Once you get into optimizing threads you are in complex territory, I'd recommend you tell the programmer to go buy a good book on it while you go have a nice cool beer. We got deeply into that many years back trying to optimize access to a hardware encryption chip for maximum throughput and minimal system load. It was successful, we got a major performance bump out of it but it was done very late in the design cycle so it wouldn't have to be redone as other portions of the program evolved. It ate a lot of programmer hours and more from the test crew to benchmark the various versions looking for the sweet spot.
User avatar
anniebrion
βeta Tester
Contact:
Location: Milkyway, Sol, Earth, UK, London
Posts: 3222
Joined: Thu Nov 05, 2009 10:39 am

Re: Memory Use (needs optimising)

Sat Jul 17, 2010 6:49 pm

I use an app called ClearMEM that triggers every 30 minutes in task scheduler, this releases RAM that is left in limbo and can shrink the amount of RAM MWP gobbles up.

http://www.pcwintech.com/cleanmem Works on Windows 2000, XP, 2003, Vista, 2008, & Win7 (32bit & 64bit)
Annie.......... PC details
Mailwasher Pro βeta [v 7.12.39]
BuBBy
Rattled Rabbit
Posts: 2
Joined: Wed May 19, 2010 9:18 pm

Re: Memory Use (needs optimising)

Sat Jul 17, 2010 7:49 pm

My point is when the user sends MWP to the notification area, you need to kick the CLR in the guts and free up what memory you can. (SetProcessWorkingSetSize -1,-1 would do quite nicely).

For example - I'm using Process Lasso, and after starting MWP it may use 140MB - I select to trim virtual memory (which is the SetProcessWorkingSetSize trick) and the same as Shanes' CleanMem on pcWinTech (something we have given a Gizmos Top Pick award for the past two years) - anyhow I digress...

After a SetProcessWorkingSetSize - memory usage drops to about 5MB and over the next 2 minutes - climbs to 11MB - I open it from the system tray - 20MB Check mailbox -> 42MB

So ignoring the specifics of how memory(working set) is being reported (I use the same figure for all steps of the application) the memory changes like so:

a. 140 MB - Launch App
b. 140 MB - Minimise to System Tray/Notification Area
c. 5 MB - Trim Memory
d. 11 MB - Wait 2 Minutes (Do nothing)
e. 20 MB - Open from System Tray
f. 23 MB - Wait 10 Minutes (Do Nothing)
g. 42 MB - Check Mail Accounts (6 accounts) and process mail
h. 7 MB - Minimise and Trim Memory

So clearly a significant memory saving could be achieved with the occasional SetProcessWorkingSetSize or similar.

There are other ways (somewhat more accurate) using perfmon or if you are more serious memprofiler.com - my point was only to show there are some savings that can be easily made - especially after the initial launch.
ru
rusticdog

Re: Memory Use (needs optimising)

Sat Jul 17, 2010 8:20 pm

In my layman understanding I don't feel that SetProcessWorkingSetSize to -1,-1 is a correct method, it simply hides the issue and could reduce overall performance.

Garbage Collector will free up memory when there is a demand for it, I don't see a need to run it constantly if there's no demand.

Return to “MailWasher Pro 7”