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

Unified Diff: base/trace_event/trace_event_memory_overhead.cc

Issue 1249643007: Align base::Pickle allocations to 4k boundaries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@accounting_fix
Patch Set: COMPILE_ASSERT -> static_assert Created 5 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
Index: base/trace_event/trace_event_memory_overhead.cc
diff --git a/base/trace_event/trace_event_memory_overhead.cc b/base/trace_event/trace_event_memory_overhead.cc
index 5ece315c00f30485ee0dce9c997b83de6007f3ee..243d007ea654310f6188cd46cd32eb6a9e124c47 100644
--- a/base/trace_event/trace_event_memory_overhead.cc
+++ b/base/trace_event/trace_event_memory_overhead.cc
@@ -6,18 +6,13 @@
#include <algorithm>
+#include "base/bits.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/memory_allocator_dump.h"
#include "base/trace_event/process_memory_dump.h"
#include "base/values.h"
-namespace {
-size_t RoundUp(size_t size, size_t alignment) {
- return (size + alignment - 1) & ~(alignment - 1);
-}
-} // namespace
-
namespace base {
namespace trace_event {
@@ -62,8 +57,8 @@ void TraceEventMemoryOverhead::AddString(const std::string& str) {
// std::string implementations:
// - even short string end up malloc()-inc at least 32 bytes.
// - longer stings seem to malloc() multiples of 16 bytes.
Lei Zhang 2015/07/24 01:36:48 BTW, typo: "stings"
Primiano Tucci (use gerrit) 2015/07/24 09:37:38 Ah, thanks
- Add("std::string",
- sizeof(std::string) + std::max<size_t>(RoundUp(str.capacity(), 16), 32u));
+ const size_t capacity = bits::Align(str.capacity(), 16);
+ Add("std::string", sizeof(std::string) + std::max<size_t>(capacity, 32u));
}
void TraceEventMemoryOverhead::AddRefCountedString(
« base/trace_event/trace_event_argument.cc ('K') | « base/trace_event/trace_event_argument.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698