This source file includes following definitions.
- GetMemoryUsageKB
- GetMemoryUsageKB
- GetMemoryUsageKB
#include "content/child/content_child_helpers.h"
#if defined(OS_LINUX)
#include <malloc.h>
#endif
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/process/process_metrics.h"
#include "v8/include/v8.h"
namespace content {
#if defined(OS_LINUX) || defined(OS_ANDROID)
size_t GetMemoryUsageKB() {
struct mallinfo minfo = mallinfo();
uint64_t mem_usage =
#if defined(USE_TCMALLOC)
minfo.uordblks
#else
(minfo.hblkhd + minfo.arena)
#endif
>> 10;
v8::HeapStatistics stat;
v8::Isolate::GetCurrent()->GetHeapStatistics(&stat);
return mem_usage + (static_cast<uint64_t>(stat.total_heap_size()) >> 10);
}
#elif defined(OS_MACOSX)
size_t GetMemoryUsageKB() {
scoped_ptr<base::ProcessMetrics> process_metrics(
base::ProcessMetrics::CreateProcessMetrics(
base::GetCurrentProcessHandle(), NULL));
return process_metrics->GetWorkingSetSize() >> 10;
}
#else
size_t GetMemoryUsageKB() {
scoped_ptr<base::ProcessMetrics> process_metrics(
base::ProcessMetrics::CreateProcessMetrics(
base::GetCurrentProcessHandle()));
return process_metrics->GetPagefileUsage() >> 10;
}
#endif
}