Date: 10/2/2009
Today I did some work on the memory foot print of Scribe v2.x at startup with a large folder file and the results are in. This morning I started with a virtual memory foot print of:
82,596 kb
Which includes all data and a lot of overhead in the memory tracking lib. The absolute figure is not really important. So I analyzed the blocks and found a huge pile of them in the Xml parser. It's blocks are primarily from loading the lr8 file and keep the Xml DOM around in memory to build dialogs, strings and menus from. So I changed that over to a ref counted string pool, that cut down a huge number of tiny allocs to a few big ones. Saves on overhead... also I free'd some of the tags I didn't need anymore. Now the footprint stands at:
72,288 kb
A good start, but what else can be done? So I did a live memory dump of Scribe running at idle after startup. And after fixing some issues with the dumping and reporting I had the results, the largest allocator in the code was creating 24.3MB in 52,924 allocations from Store3Mail2.cpp:119. So I looked at that line:
return new MailData(this);
So I looked at the size of that object, and it's over 400 bytes. Owwww, that doesn't sound right. So I dug through the members and isolated the object blowing the size out. There was no easy way to remove the bulk of that object as it inherits from UI objects, however there is no real need to use that exact object, so I reimplemented a smaller implementation of the required interfaces and got the size of the MailData object down to 280 bytes. That brings the total memory footprint down to:
41,736 kb
Even nicer... Thats not bad eh! Half the memory usage.
Update: So today I did some more snooping around the memory footprint and found that all the mail2 folders are loading their entire contents into memory as objects. Normally I delay loading of items till they are needed, or at least thats the way it worked in v1.x, so I changed the Store3/Mail2 backend to work the same way as v1 and delay loading objects...
20,700 kb
Damn straight.
11/02/2009 5:56am
That rocks! Awesome.
Email (optional): (Will be HTML encoded to evade harvesting)
Remember username and/or email in a cookie.
Notify me of new posts in this thread via email.