On 19 Sep, Sean Ward wrote:
> Yep, freeamp as a whole is a lot more bloated than say, winamp or XMMS. The
> primary size difference comes from the musicbrowser, because it loads all
> the metadata entries at startup, so has a memory footprint proportional to
> the number of tracks in your collection. Additionally, there are a bit too
> many internal copies which go on, which are part of the general musicbrowser
> issue ;).
I did some basic snooping around in the codebase to see why we use so
much memory and what we can do about it. First, the musicbrowser and the
musiccatalog duplicate the playlist items, which is a known bug and
would take a serious amount of work to take care of.
Second is the our abundant use of string objects, especially in the
Metadata class. There are 7 string objects (m_artist, m_album, m _title,
m_genre, m_comment, m_extension, m_guid) which may or may not be all
filled out.
So I wrote a quick program to compare normal C string use with the
string object which allocates 10000 20 byte strings and tosses them into
a vector:
10000 20 byte traditional strings:
16271 robert 8 0 3080 3080 284 S 0 0.0 4.7 0:00 a.out
10000 20 byte strings:
16264 robert 8 0 7244 7244 436 S 0 0.0 11.2 0:00 vstring
10000 2 byte strings:
16250 robert 8 0 7244 7244 436 S 0 0.0 11.2 0:00 vstring
The C++ string class uses more than twice as much memory as the
traditional string stuff. Even more eyeopening is the fact that there is
no difference between a 10000 2 byte strings and 10000 20 byte strings.
So, I would propose the following as a footprint reducing measure that
we could easily implement before we release 2.1 and somewhat ease
crunch.
1) Find some code on the net that manages a freestore for small strings
2) Add an instance of the freestore to the context object so its
available all over the place.
3) Instead of using strings in the Metadata class, we use pointers to
entries in the freestore. We convert to and from strings when the
accessor methods are called.
The only outside code change that needs to happen is that when someone
creates a metadata/playlist object, the freestore pointer needs to get
passed in.
A freestore memory footprint for the above should look similar to this:
10000 20 byte freestore strings:
16308 robert 7 0 2400 2400 284 S 0 0.0 3.7 0:00 a.out
7244 down to 2400 is not a bad improvement. Thoughts?
--ruaok Freezerburn! All else is only icing. -- Soul Coughing
Robert Kaye -- [EMAIL PROTECTED] http://moon.eorbit.net/~robert
_______________________________________________
[EMAIL PROTECTED]
http://www.freeamp.org/mailman/listinfo/freeamp-dev