Add database memory usage to 'get_counts' output.

This commit is contained in:
JoelKatz
2013-02-04 23:37:44 -08:00
parent 2564b6a60b
commit 1b2c0b9242
4 changed files with 11 additions and 0 deletions

View File

@@ -196,6 +196,10 @@ uint64 SqliteDatabase::getBigInt(int colIndex)
return(sqlite3_column_int64(mCurrentStmt, colIndex));
}
int SqliteDatabase::getKBUsed()
{
return static_cast<int>(sqlite3_memory_used() / 1024);
}
static int SqliteWALHook(void *s, sqlite3* dbCon, const char *dbName, int walSize)
{

View File

@@ -57,6 +57,8 @@ public:
void runWal();
void doHook(const char *db, int walSize);
int getKBUsed();
};
class SqliteStatement

View File

@@ -89,6 +89,7 @@ public:
virtual bool setupCheckpointing(JobQueue*) { return false; }
virtual SqliteDatabase* getSqliteDB() { return NULL; }
virtual int getKBUsed() { return -1; }
};
#endif

View File

@@ -1803,6 +1803,10 @@ Json::Value RPCHandler::doGetCounts(Json::Value jvRequest)
BOOST_FOREACH(InstanceType::InstanceCount& it, count)
ret[it.first] = it.second;
int dbKB = theApp->getLedgerDB()->getDB()->getKBUsed();
if (dbKB > 0)
ret["dbKB"] = dbKB;
return ret;
}