mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
memory manage statistics
Summary: Earlier Statistics object was a raw pointer. This meant the user had to clear up the Statistics object after creating the database. In most use cases the database is created in a function and the statistics pointer is out of scope. Hence the statistics object would never be deleted. Now Using a shared_ptr to manage this. Want this in before the next release. Test Plan: make all check. Reviewers: dhruba, emayanke Reviewed By: emayanke CC: leveldb Differential Revision: https://reviews.facebook.net/D9735
This commit is contained in:
@@ -101,7 +101,7 @@ static const char* FLAGS_db = nullptr;
|
||||
static bool FLAGS_verify_checksum = false;
|
||||
|
||||
// Database statistics
|
||||
static class leveldb::DBStatistics* dbstats;
|
||||
static std::shared_ptr<leveldb::Statistics> dbstats;
|
||||
|
||||
// Sync all writes to disk
|
||||
static bool FLAGS_sync = false;
|
||||
@@ -1045,7 +1045,7 @@ int main(int argc, char** argv) {
|
||||
} else if (sscanf(argv[i], "--statistics=%d%c", &n, &junk) == 1 &&
|
||||
(n == 0 || n == 1)) {
|
||||
if (n == 1) {
|
||||
dbstats = new leveldb::DBStatistics();
|
||||
dbstats.reset(new leveldb::DBStatistics());
|
||||
}
|
||||
} else if (sscanf(argv[i], "--sync=%d%c", &n, &junk) == 1 &&
|
||||
(n == 0 || n == 1)) {
|
||||
@@ -1131,8 +1131,5 @@ int main(int argc, char** argv) {
|
||||
|
||||
leveldb::StressTest stress;
|
||||
stress.Run();
|
||||
if (dbstats) {
|
||||
delete dbstats;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user