Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Unified Diff: content/common/gpu/gpu_memory_manager.cc

Issue 10796096: Add tracing of all memory allocated in all contexts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More trybot constructor fixes Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/gpu/gpu_memory_manager.h ('k') | gpu/command_buffer/service/buffer_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/gpu_memory_manager.cc
diff --git a/content/common/gpu/gpu_memory_manager.cc b/content/common/gpu/gpu_memory_manager.cc
index 39b8e48175e3ccec42fd0d52bb15f8a7d4433387..10883287bcc803ef7c16f44f85ed54d58757154b 100644
--- a/content/common/gpu/gpu_memory_manager.cc
+++ b/content/common/gpu/gpu_memory_manager.cc
@@ -9,6 +9,7 @@
#include <algorithm>
#include "base/bind.h"
+#include "base/debug/trace_event.h"
#include "base/message_loop.h"
#include "content/common/gpu/gpu_command_buffer_stub.h"
#include "content/common/gpu/gpu_memory_allocation.h"
@@ -70,7 +71,8 @@ GpuMemoryManager::GpuMemoryManager(GpuMemoryManagerClient* client,
manage_immediate_scheduled_(false),
max_surfaces_with_frontbuffer_soft_limit_(
max_surfaces_with_frontbuffer_soft_limit),
- peak_assigned_allocation_sum_(0) {
+ bytes_allocated_current_(0),
+ bytes_allocated_historical_max_(0) {
}
GpuMemoryManager::~GpuMemoryManager() {
@@ -115,6 +117,29 @@ size_t GpuMemoryManager::GetAvailableGpuMemory() const {
return kMaximumAllocationForTabs;
}
+void GpuMemoryManager::TrackMemoryAllocatedChange(size_t old_size,
+ size_t new_size)
+{
+ if (new_size < old_size) {
+ size_t delta = old_size - new_size;
+ DCHECK(bytes_allocated_current_ >= delta);
+ bytes_allocated_current_ -= delta;
+ }
+ else {
+ size_t delta = new_size - old_size;
+ bytes_allocated_current_ += delta;
+ if (bytes_allocated_current_ > bytes_allocated_historical_max_) {
+ bytes_allocated_historical_max_ = bytes_allocated_current_;
+ }
+ }
+ if (new_size != old_size) {
+ TRACE_COUNTER_ID1("GpuMemoryManager",
+ "GpuMemoryUsage",
+ this,
+ bytes_allocated_current_);
+ }
+}
+
// The current Manage algorithm simply classifies contexts (stubs) into
// "foreground", "background", or "hibernated" categories.
// For each of these three categories, there are predefined memory allocation
@@ -278,9 +303,6 @@ void GpuMemoryManager::Manage() {
++it) {
assigned_allocation_sum += it->second.allocation.gpu_resource_size_in_bytes;
}
-
- if (assigned_allocation_sum > peak_assigned_allocation_sum_)
- peak_assigned_allocation_sum_ = assigned_allocation_sum;
}
#endif
« no previous file with comments | « content/common/gpu/gpu_memory_manager.h ('k') | gpu/command_buffer/service/buffer_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698