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

Unified Diff: base/trace_event/heap_profiler_allocation_register_unittest.cc

Issue 1530583003: [Tracing] Adjust allocation register size for low-end devices (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: CR Feedback Created 5 years 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 | « base/trace_event/heap_profiler_allocation_register.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/heap_profiler_allocation_register_unittest.cc
diff --git a/base/trace_event/heap_profiler_allocation_register_unittest.cc b/base/trace_event/heap_profiler_allocation_register_unittest.cc
index 6058f470e9d654b69d8178734e3be1d0af0f4577..51d36e978683cec562cf1e94644cd8f266eabc0d 100644
--- a/base/trace_event/heap_profiler_allocation_register_unittest.cc
+++ b/base/trace_event/heap_profiler_allocation_register_unittest.cc
@@ -14,7 +14,6 @@ namespace trace_event {
class AllocationRegisterTest : public testing::Test {
public:
static const uint32_t kNumBuckets = AllocationRegister::kNumBuckets;
- static const uint32_t kNumCells = AllocationRegister::kNumCells;
// Returns the number of cells that the |AllocationRegister| can store per
// system page.
@@ -25,6 +24,10 @@ class AllocationRegisterTest : public testing::Test {
uint32_t GetHighWaterMark(const AllocationRegister& reg) {
return reg.next_unused_cell_;
}
+
+ uint32_t GetNumCells(const AllocationRegister& reg) {
+ return reg.num_cells_;
+ }
};
// Iterates over all entries in the allocation register and returns the bitwise
@@ -203,14 +206,15 @@ TEST_F(AllocationRegisterTest, InsertRemoveRandomOrder) {
// too many elements.
#if GTEST_HAS_DEATH_TEST
TEST_F(AllocationRegisterTest, OverflowDeathTest) {
- AllocationRegister reg;
+ // Use a smaller register to prevent OOM errors on low-end devices.
+ AllocationRegister reg(GetNumCellsPerPage());
AllocationContext ctx = AllocationContext::Empty();
uintptr_t i;
- // Fill up all of the memory allocated for the register. |kNumCells| minus 1
- // elements are inserted, because cell 0 is unused, so this should fill up
- // the available cells exactly.
- for (i = 1; i < kNumCells; i++) {
+ // Fill up all of the memory allocated for the register. |GetNumCells(reg)|
+ // minus 1 elements are inserted, because cell 0 is unused, so this should
+ // fill up the available cells exactly.
+ for (i = 1; i < GetNumCells(reg); i++) {
reg.Insert(reinterpret_cast<void*>(i), 0, ctx);
}
« no previous file with comments | « base/trace_event/heap_profiler_allocation_register.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698