Tuning Songbird Memory Usage

As of version 1.1 Songbird offers advanced preferences for controlling how much memory is used displaying your library.  Try changing these values if you'd like to conserve RAM, or want more of your library cached in memory.

about_config.pngPlease be aware that changes to these settings may severely hurt launch time, scrolling performance, and filtering. While unlikely, it is possible that you may need to delete your profile to make Songbird work again.

Before experimenting you should probably read Dynamic Memory Allocation In SQLite

To change preferences, open up a new tab and enter "about:config" in the address bar and press return.  To create a new preference key, right click, select New > Integer, and enter the preference name and value.   

Available Preferences

songbird.dbengine.pageSize
The size (in bytes) of each page in the database.  This preference will only work when set before a database is created.  You probably want to leave it alone.

songbird.dbengine.cacheSize
The maximum number of pages that should be kept in memory for each open database.

songbird.dbengine.preAllocCacheSize
At startup, set aside this many pages for page cache use.  Avoids fragmentation, but raises base memory usage, since the memory is allocated even if it isn't needed. See 3.3 Page cache memory

songbird.dbengine.preAllocScratchSize
Number of scratch slots to set aside at startup.  Scratch memory is used for temporary calculations.   There is no need for more than one per database thread.  See 3.2 Scratch memory

songbird.dbengine.softHeapLimit
An upper limit (in bytes) on the amount of memory sqlite should try to use.  This includes all databases. See 3.6 Setting memory usage limits

You can also configure pageSize and cacheSize on a per-database level by inserting the database name into the key. For example,  songbird.dbengine.web@library.songbirdnest.com.cacheSize could be used to restrict the cache given to media found on the web.


Measuring Usage

To determine how much memory the database is consuming, open the Tools > Error Console, and run the following code snippet:
Components.classes["@songbirdnest.com/Songbird/DatabaseEngine;1"].getService(Components.interfaces.sbIDatabaseEngine).dumpMemoryStatistics();

Which will output something in the console like:

DumpMemoryStatistics() format       Current    Highwater 
SQLITE_STATUS_MEMORY_USED: 4949544 5162520
SQLITE_STATUS_PAGECACHE_USED: 0 0
SQLITE_STATUS_PAGECACHE_OVERFLOW: 4521984 4651008
SQLITE_STATUS_SCRATCH_USED: 0 0
SQLITE_STATUS_SCRATCH_OVERFLOW: 0 4672
SQLITE_STATUS_MALLOC_SIZE 216 52000
SQLITE_STATUS_PARSER_STACK 0 0
SQLITE_STATUS_PAGECACHE_SIZE 16384 16384
SQLITE_STATUS_SCRATCH_SIZE 4552 4672

In this example no cache or scratch memory was preallocated, and instead all memory was acquired via regular malloc when requested.
To interpret this output read 3.5 Memory status


Sample Scenarios

If you have gigabytes of RAM and a very large music library, you may want to cache your entire database in memory.  To do this, you can look at the size of your database on disk in <yourprofile>/db/main@library.songbirdnest.com.db and divide it by 16,384. This gives you the maximum number of database pages in the database. For example, I have a large library which has a 150MB database file, or about 9200 pages. Here I'll set the cache size to 9200 to allow Songbird to keep the whole database in memory, and the preAllocCacheSize to 50% of that.
songbird.dbengine.cacheSize = 9200
songbird.dbengine.preAllocCacheSize = 4600


This says that each database may use up to about a gigabyte for page caching, and that 16MB should be set aside at launch (assuming 16384 byte pages).

If you have little RAM to spare, you could restrict memory usage to 10% of your collection size. For example, my profile with about 6,700 songs has a 13mb database, or about 800 pages. I'll restrict its usage to 10% of that and give it a soft heap limit of 3MB.
songbird.dbengine.cacheSize = 80
songbird.dbengine.softHeapLimit = 3145728

which means allow each database a maximum of about 1.5MB, but also attempt to limit the overall memory usage to 3MB.   

If you experiment and come up with settings that work well, please comment below.
Tag page
You must login to post a comment.