Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "sql/sql_memory_dump_provider.h" | |
| 6 | |
| 7 #include "base/trace_event/memory_dump_manager.h" | |
| 8 #include "base/trace_event/process_memory_dump.h" | |
| 9 #include "third_party/sqlite/sqlite3.h" | |
| 10 | |
| 11 namespace sql { | |
| 12 | |
| 13 // static | |
| 14 SqlMemoryDumpProvider* SqlMemoryDumpProvider::GetInstance() { | |
| 15 return base::Singleton< | |
| 16 SqlMemoryDumpProvider, | |
| 17 base::LeakySingletonTraits<SqlMemoryDumpProvider>>::get(); | |
| 18 } | |
| 19 | |
| 20 SqlMemoryDumpProvider::SqlMemoryDumpProvider() {} | |
| 21 | |
| 22 SqlMemoryDumpProvider::~SqlMemoryDumpProvider() {} | |
| 23 | |
| 24 bool SqlMemoryDumpProvider::OnMemoryDump( | |
| 25 const base::trace_event::MemoryDumpArgs& args, | |
| 26 base::trace_event::ProcessMemoryDump* pmd) { | |
| 27 base::trace_event::MemoryAllocatorDump* dump = | |
| 28 pmd->CreateAllocatorDump("sqlite"); | |
| 29 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | |
| 30 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | |
| 31 sqlite3_memory_used()); | |
| 32 dump->AddScalar("malloc_high_wmark_size", | |
| 33 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | |
| 34 sqlite3_memory_highwater(1 /*resetFlag */)); | |
|
Scott Hess - ex-Googler
2015/10/07 23:08:57
sqlite3_memory_used() is literally sqlite3_status(
ssid
2015/10/08 16:53:59
I see. I thought getting them separately was faste
| |
| 35 | |
| 36 int status; | |
| 37 int dummy_high_water = -1; | |
| 38 int malloc_count = -1; | |
| 39 status = sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &malloc_count, | |
| 40 &dummy_high_water, 0 /* resetFlag */); | |
| 41 if (status == SQLITE_OK) { | |
| 42 dump->AddScalar("malloc_count", | |
| 43 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | |
| 44 malloc_count); | |
| 45 } | |
| 46 | |
| 47 const char* system_allocator_name = | |
| 48 base::trace_event::MemoryDumpManager::GetInstance() | |
| 49 ->system_allocator_pool_name(); | |
| 50 if (system_allocator_name) { | |
| 51 pmd->AddSuballocation(dump->guid(), system_allocator_name); | |
| 52 } | |
| 53 return true; | |
| 54 } | |
| 55 | |
| 56 } // namespace sql | |
| OLD | NEW |