Commit 8e7faebf authored by ruuda's avatar ruuda Committed by Commit bot

Remove unused memory functions

In |blink::Platform|, the functions |processMemorySizesInBytes| and
|memoryAllocatorWasteInBytes| are unused. Let's remove them.

The function |base::allocator::GetAllocatorWasteSize| is not used
anywhere except in the unused Blink functions, so it can be removed as
well.

Detailed information about memory allocators is available in the memory-
infra category of chrome://tracing. It supports all allocators, not just
tcmalloc. |GetAllocatorWasteSize| was implemented for tcmalloc only.

Review URL: https://codereview.chromium.org/1468033002

Cr-Commit-Position: refs/heads/master@{#361303}
parent 04b8bd2e
...@@ -9,13 +9,6 @@ ...@@ -9,13 +9,6 @@
namespace base { namespace base {
namespace allocator { namespace allocator {
bool GetAllocatorWasteSize(size_t* size) {
thunks::GetAllocatorWasteSizeFunction get_allocator_waste_size_function =
thunks::GetGetAllocatorWasteSizeFunction();
return get_allocator_waste_size_function != NULL &&
get_allocator_waste_size_function(size);
}
void GetStats(char* buffer, int buffer_length) { void GetStats(char* buffer, int buffer_length) {
DCHECK_GT(buffer_length, 0); DCHECK_GT(buffer_length, 0);
thunks::GetStatsFunction get_stats_function = thunks::GetGetStatsFunction(); thunks::GetStatsFunction get_stats_function = thunks::GetGetStatsFunction();
...@@ -32,13 +25,6 @@ void ReleaseFreeMemory() { ...@@ -32,13 +25,6 @@ void ReleaseFreeMemory() {
release_free_memory_function(); release_free_memory_function();
} }
void SetGetAllocatorWasteSizeFunction(
thunks::GetAllocatorWasteSizeFunction get_allocator_waste_size_function) {
DCHECK_EQ(thunks::GetGetAllocatorWasteSizeFunction(),
reinterpret_cast<thunks::GetAllocatorWasteSizeFunction>(NULL));
thunks::SetGetAllocatorWasteSizeFunction(get_allocator_waste_size_function);
}
void SetGetStatsFunction(thunks::GetStatsFunction get_stats_function) { void SetGetStatsFunction(thunks::GetStatsFunction get_stats_function) {
DCHECK_EQ(thunks::GetGetStatsFunction(), DCHECK_EQ(thunks::GetGetStatsFunction(),
reinterpret_cast<thunks::GetStatsFunction>(NULL)); reinterpret_cast<thunks::GetStatsFunction>(NULL));
......
...@@ -14,15 +14,6 @@ ...@@ -14,15 +14,6 @@
namespace base { namespace base {
namespace allocator { namespace allocator {
// Request the allocator to report value of its waste memory size.
// Waste size corresponds to memory that has been allocated from the OS but
// not passed up to the application. It e.g. includes memory retained by free
// lists, internal data, chunks padding, etc.
//
// |size| pointer to the returned value, must be not NULL.
// Returns true if the value has been returned, false otherwise.
BASE_EXPORT bool GetAllocatorWasteSize(size_t* size);
// Request that the allocator print a human-readable description of the current // Request that the allocator print a human-readable description of the current
// state of the allocator into a null-terminated string in the memory segment // state of the allocator into a null-terminated string in the memory segment
// buffer[0,buffer_length-1]. // buffer[0,buffer_length-1].
...@@ -44,8 +35,6 @@ BASE_EXPORT void ReleaseFreeMemory(); ...@@ -44,8 +35,6 @@ BASE_EXPORT void ReleaseFreeMemory();
// No threading promises are made. The caller is responsible for making sure // No threading promises are made. The caller is responsible for making sure
// these pointers are set before any other threads attempt to call the above // these pointers are set before any other threads attempt to call the above
// functions. // functions.
BASE_EXPORT void SetGetAllocatorWasteSizeFunction(
thunks::GetAllocatorWasteSizeFunction get_allocator_waste_size_function);
BASE_EXPORT void SetGetStatsFunction( BASE_EXPORT void SetGetStatsFunction(
thunks::GetStatsFunction get_stats_function); thunks::GetStatsFunction get_stats_function);
......
...@@ -17,20 +17,10 @@ namespace thunks { ...@@ -17,20 +17,10 @@ namespace thunks {
// can depend on it. This file can't depend on anything else in base, including // can depend on it. This file can't depend on anything else in base, including
// logging. // logging.
static GetAllocatorWasteSizeFunction g_get_allocator_waste_size_function = NULL;
static GetStatsFunction g_get_stats_function = NULL; static GetStatsFunction g_get_stats_function = NULL;
static ReleaseFreeMemoryFunction g_release_free_memory_function = NULL; static ReleaseFreeMemoryFunction g_release_free_memory_function = NULL;
static GetNumericPropertyFunction g_get_numeric_property_function = NULL; static GetNumericPropertyFunction g_get_numeric_property_function = NULL;
void SetGetAllocatorWasteSizeFunction(
GetAllocatorWasteSizeFunction get_allocator_waste_size_function) {
g_get_allocator_waste_size_function = get_allocator_waste_size_function;
}
GetAllocatorWasteSizeFunction GetGetAllocatorWasteSizeFunction() {
return g_get_allocator_waste_size_function;
}
void SetGetStatsFunction(GetStatsFunction get_stats_function) { void SetGetStatsFunction(GetStatsFunction get_stats_function) {
g_get_stats_function = get_stats_function; g_get_stats_function = get_stats_function;
} }
......
...@@ -15,11 +15,6 @@ namespace thunks { ...@@ -15,11 +15,6 @@ namespace thunks {
// new allocator extension from a specific allocator implementation to base. // new allocator extension from a specific allocator implementation to base.
// See allocator_extension.h to see the interface that base exports. // See allocator_extension.h to see the interface that base exports.
typedef bool (*GetAllocatorWasteSizeFunction)(size_t* size);
void SetGetAllocatorWasteSizeFunction(
GetAllocatorWasteSizeFunction get_allocator_waste_size_function);
GetAllocatorWasteSizeFunction GetGetAllocatorWasteSizeFunction();
typedef void (*GetStatsFunction)(char* buffer, int buffer_length); typedef void (*GetStatsFunction)(char* buffer, int buffer_length);
void SetGetStatsFunction(GetStatsFunction get_stats_function); void SetGetStatsFunction(GetStatsFunction get_stats_function);
GetStatsFunction GetGetStatsFunction(); GetStatsFunction GetGetStatsFunction();
......
...@@ -414,21 +414,6 @@ class ContentMainRunnerImpl : public ContentMainRunner { ...@@ -414,21 +414,6 @@ class ContentMainRunnerImpl : public ContentMainRunner {
} }
#if defined(USE_TCMALLOC) #if defined(USE_TCMALLOC)
static bool GetAllocatorWasteSizeThunk(size_t* size) {
size_t heap_size, allocated_bytes, unmapped_bytes;
MallocExtension* ext = MallocExtension::instance();
if (ext->GetNumericProperty("generic.heap_size", &heap_size) &&
ext->GetNumericProperty("generic.current_allocated_bytes",
&allocated_bytes) &&
ext->GetNumericProperty("tcmalloc.pageheap_unmapped_bytes",
&unmapped_bytes)) {
*size = heap_size - allocated_bytes - unmapped_bytes;
return true;
}
DCHECK(false);
return false;
}
static void GetStatsThunk(char* buffer, int buffer_length) { static void GetStatsThunk(char* buffer, int buffer_length) {
MallocExtension::instance()->GetStats(buffer, buffer_length); MallocExtension::instance()->GetStats(buffer, buffer_length);
} }
...@@ -471,8 +456,6 @@ class ContentMainRunnerImpl : public ContentMainRunner { ...@@ -471,8 +456,6 @@ class ContentMainRunnerImpl : public ContentMainRunner {
tc_set_new_mode(1); tc_set_new_mode(1);
// On windows, we've already set these thunks up in _heap_init() // On windows, we've already set these thunks up in _heap_init()
base::allocator::SetGetAllocatorWasteSizeFunction(
GetAllocatorWasteSizeThunk);
base::allocator::SetGetStatsFunction(GetStatsThunk); base::allocator::SetGetStatsFunction(GetStatsThunk);
base::allocator::SetGetNumericPropertyFunction(GetNumericPropertyThunk); base::allocator::SetGetNumericPropertyFunction(GetNumericPropertyThunk);
base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk);
......
...@@ -149,8 +149,6 @@ RenderMessageFilter::~RenderMessageFilter() { ...@@ -149,8 +149,6 @@ RenderMessageFilter::~RenderMessageFilter() {
bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message) { bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true; bool handled = true;
IPC_BEGIN_MESSAGE_MAP(RenderMessageFilter, message) IPC_BEGIN_MESSAGE_MAP(RenderMessageFilter, message)
IPC_MESSAGE_HANDLER(RenderProcessHostMsg_GetProcessMemorySizes,
OnGetProcessMemorySizes)
IPC_MESSAGE_HANDLER(ViewHostMsg_GenerateRoutingID, OnGenerateRoutingID) IPC_MESSAGE_HANDLER(ViewHostMsg_GenerateRoutingID, OnGenerateRoutingID)
IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWindow, OnCreateWindow) IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWindow, OnCreateWindow)
IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnCreateWidget) IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnCreateWidget)
...@@ -291,24 +289,6 @@ void RenderMessageFilter::OnCreateFullscreenWidget(int opener_id, ...@@ -291,24 +289,6 @@ void RenderMessageFilter::OnCreateFullscreenWidget(int opener_id,
render_widget_helper_->CreateNewFullscreenWidget(opener_id, route_id); render_widget_helper_->CreateNewFullscreenWidget(opener_id, route_id);
} }
void RenderMessageFilter::OnGetProcessMemorySizes(size_t* private_bytes,
size_t* shared_bytes) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
using base::ProcessMetrics;
#if !defined(OS_MACOSX) || defined(OS_IOS)
scoped_ptr<ProcessMetrics> metrics(ProcessMetrics::CreateProcessMetrics(
PeerHandle()));
#else
scoped_ptr<ProcessMetrics> metrics(ProcessMetrics::CreateProcessMetrics(
PeerHandle(), BrowserChildProcessHost::GetPortProvider()));
#endif
if (!metrics->GetMemoryBytes(private_bytes, shared_bytes)) {
*private_bytes = 0;
*shared_bytes = 0;
}
}
void RenderMessageFilter::OnGenerateRoutingID(int* route_id) { void RenderMessageFilter::OnGenerateRoutingID(int* route_id) {
*route_id = render_widget_helper_->GetNextRoutingID(); *route_id = render_widget_helper_->GetNextRoutingID();
} }
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <vector> #include <vector>
#include "base/allocator/allocator_extension.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/location.h" #include "base/location.h"
...@@ -16,7 +15,6 @@ ...@@ -16,7 +15,6 @@
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/metrics/sparse_histogram.h" #include "base/metrics/sparse_histogram.h"
#include "base/process/process_metrics.h"
#include "base/rand_util.h" #include "base/rand_util.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
...@@ -1251,18 +1249,6 @@ size_t BlinkPlatformImpl::numberOfProcessors() { ...@@ -1251,18 +1249,6 @@ size_t BlinkPlatformImpl::numberOfProcessors() {
return static_cast<size_t>(base::SysInfo::NumberOfProcessors()); return static_cast<size_t>(base::SysInfo::NumberOfProcessors());
} }
bool BlinkPlatformImpl::processMemorySizesInBytes(
size_t* private_bytes,
size_t* shared_bytes) {
scoped_ptr<base::ProcessMetrics> current_process_metrics(
base::ProcessMetrics::CreateCurrentProcessMetrics());
return current_process_metrics->GetMemoryBytes(private_bytes, shared_bytes);
}
bool BlinkPlatformImpl::memoryAllocatorWasteInBytes(size_t* size) {
return base::allocator::GetAllocatorWasteSize(size);
}
blink::WebDiscardableMemory* blink::WebDiscardableMemory*
BlinkPlatformImpl::allocateAndLockDiscardableMemory(size_t bytes) { BlinkPlatformImpl::allocateAndLockDiscardableMemory(size_t bytes) {
return content::WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release(); return content::WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release();
......
...@@ -77,9 +77,6 @@ class CONTENT_EXPORT BlinkPlatformImpl ...@@ -77,9 +77,6 @@ class CONTENT_EXPORT BlinkPlatformImpl
bool isLowEndDeviceMode() override; bool isLowEndDeviceMode() override;
size_t numberOfProcessors() override; size_t numberOfProcessors() override;
bool processMemorySizesInBytes(size_t* private_bytes,
size_t* shared_bytes) override;
bool memoryAllocatorWasteInBytes(size_t* size) override;
blink::WebDiscardableMemory* allocateAndLockDiscardableMemory( blink::WebDiscardableMemory* allocateAndLockDiscardableMemory(
size_t bytes) override; size_t bytes) override;
size_t maxDecodedImageBytes() override; size_t maxDecodedImageBytes() override;
......
...@@ -55,11 +55,6 @@ IPC_MESSAGE_CONTROL3(RenderProcessHostMsg_DidGenerateCacheableMetadata, ...@@ -55,11 +55,6 @@ IPC_MESSAGE_CONTROL3(RenderProcessHostMsg_DidGenerateCacheableMetadata,
IPC_MESSAGE_CONTROL1(RenderProcessHostMsg_SuddenTerminationChanged, IPC_MESSAGE_CONTROL1(RenderProcessHostMsg_SuddenTerminationChanged,
bool /* enabled */) bool /* enabled */)
// Asks the browser for the renderer process memory size stats.
IPC_SYNC_MESSAGE_CONTROL0_2(RenderProcessHostMsg_GetProcessMemorySizes,
size_t /* private_bytes */,
size_t /* shared_bytes */)
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// Request that the browser load a font into shared memory for us. // Request that the browser load a font into shared memory for us.
IPC_SYNC_MESSAGE_CONTROL1_3(RenderProcessHostMsg_LoadFont, IPC_SYNC_MESSAGE_CONTROL1_3(RenderProcessHostMsg_LoadFont,
......
...@@ -975,17 +975,6 @@ blink::WebSpeechSynthesizer* RendererBlinkPlatformImpl::createSpeechSynthesizer( ...@@ -975,17 +975,6 @@ blink::WebSpeechSynthesizer* RendererBlinkPlatformImpl::createSpeechSynthesizer(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool RendererBlinkPlatformImpl::processMemorySizesInBytes(
size_t* private_bytes,
size_t* shared_bytes) {
content::RenderThread::Get()->Send(
new RenderProcessHostMsg_GetProcessMemorySizes(
private_bytes, shared_bytes));
return true;
}
//------------------------------------------------------------------------------
blink::WebGraphicsContext3D* blink::WebGraphicsContext3D*
RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D( RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D(
const blink::WebGraphicsContext3D::Attributes& attributes) { const blink::WebGraphicsContext3D::Attributes& attributes) {
......
...@@ -141,8 +141,6 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { ...@@ -141,8 +141,6 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
blink::WebMediaRecorderHandler* createMediaRecorderHandler() override; blink::WebMediaRecorderHandler* createMediaRecorderHandler() override;
blink::WebMediaStreamCenter* createMediaStreamCenter( blink::WebMediaStreamCenter* createMediaStreamCenter(
blink::WebMediaStreamCenterClient* client) override; blink::WebMediaStreamCenterClient* client) override;
bool processMemorySizesInBytes(size_t* private_bytes,
size_t* shared_bytes) override;
blink::WebGraphicsContext3D* createOffscreenGraphicsContext3D( blink::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
const blink::WebGraphicsContext3D::Attributes& attributes) override; const blink::WebGraphicsContext3D::Attributes& attributes) override;
blink::WebGraphicsContext3D* createOffscreenGraphicsContext3D( blink::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
......
...@@ -276,15 +276,6 @@ public: ...@@ -276,15 +276,6 @@ public:
// Return the number of of processors of the current machine. // Return the number of of processors of the current machine.
virtual size_t numberOfProcessors() { return 0; } virtual size_t numberOfProcessors() { return 0; }
// Returns private and shared usage, in bytes. Private bytes is the amount of
// memory currently allocated to this process that cannot be shared. Returns
// false on platform specific error conditions.
virtual bool processMemorySizesInBytes(size_t* privateBytes, size_t* sharedBytes) { return false; }
// Reports number of bytes used by memory allocator for internal needs.
// Returns true if the size has been reported, or false otherwise.
virtual bool memoryAllocatorWasteInBytes(size_t*) { return false; }
// Allocates discardable memory. May return nullptr, even if the platform supports // Allocates discardable memory. May return nullptr, even if the platform supports
// discardable memory. If nonzero, however, then the WebDiscardableMmeory is // discardable memory. If nonzero, however, then the WebDiscardableMmeory is
// returned in an locked state. You may use its underlying data() member // returned in an locked state. You may use its underlying data() member
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment