b=566442; add memory reporters for sqlite; r=sdwilsh

This commit is contained in:
Vladimir Vukicevic 2010-05-19 13:46:08 -07:00
Родитель 44b832e7ed
Коммит e94d4e8f48
1 изменённых файлов: 14 добавлений и 6 удалений

Просмотреть файл

@ -56,6 +56,7 @@
#include "sqlite3.h" #include "sqlite3.h"
#include "nsIPromptService.h" #include "nsIPromptService.h"
#include "nsIMemoryReporter.h"
namespace mozilla { namespace mozilla {
namespace storage { namespace storage {
@ -71,6 +72,16 @@ NS_IMPL_THREADSAFE_ISUPPORTS2(
Service *Service::gService = nsnull; Service *Service::gService = nsnull;
static PRInt64 GetStorageSQLiteMemoryUsed(void *) {
return sqlite3_memory_used();
}
NS_MEMORY_REPORTER_IMPLEMENT(StorageSQLiteMemoryUsed,
"storage/sqlite",
"Memory in use by SQLite",
GetStorageSQLiteMemoryUsed,
nsnull)
Service * Service *
Service::getSingleton() Service::getSingleton()
{ {
@ -102,6 +113,8 @@ Service::getSingleton()
NS_RELEASE(gService); NS_RELEASE(gService);
} }
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(StorageSQLiteMemoryUsed));
return gService; return gService;
} }
@ -147,12 +160,7 @@ Service::shutdown()
nsresult nsresult
Service::initialize() Service::initialize()
{ {
// Disable memory allocation statistic collection, improving performance. int rc;
// This must be done prior to a call to sqlite3_initialize to have any
// effect.
int rc = ::sqlite3_config(SQLITE_CONFIG_MEMSTATUS, 0);
if (rc != SQLITE_OK)
return convertResultCode(rc);
// Explicitly initialize sqlite3. Although this is implicitly called by // Explicitly initialize sqlite3. Although this is implicitly called by
// various sqlite3 functions (and the sqlite3_open calls in our case), // various sqlite3 functions (and the sqlite3_open calls in our case),