Lines Matching refs:Memory
5 #include "base/memory/discardable_memory_ashmem_allocator.h"
10 #include "base/memory/discardable_memory.h"
11 #include "base/memory/scoped_ptr.h"
38 void WriteToDiscardableAshmemChunk(DiscardableAshmemChunk* memory,
42 static_cast<char*>(memory->Memory())[0] = 'a';
43 static_cast<char*>(memory->Memory())[size - 1] = 'a';
48 scoped_ptr<DiscardableAshmemChunk> memory(allocator_.Allocate(size));
49 ASSERT_TRUE(memory);
50 WriteToDiscardableAshmemChunk(memory.get(), size);
54 scoped_ptr<DiscardableAshmemChunk> memory(allocator_.Allocate(0));
55 ASSERT_FALSE(memory);
59 scoped_ptr<DiscardableAshmemChunk> memory(
63 ASSERT_FALSE(memory);
74 scoped_ptr<DiscardableAshmemChunk> memory(
76 ASSERT_FALSE(memory);
85 scoped_ptr<DiscardableAshmemChunk> memory(allocator.Allocate(kPageSize));
86 ASSERT_TRUE(memory);
93 scoped_ptr<DiscardableAshmemChunk> memory(allocator_.Allocate(size));
94 ASSERT_TRUE(memory);
95 WriteToDiscardableAshmemChunk(memory.get(), size);
99 scoped_ptr<DiscardableAshmemChunk> memory(allocator_.Allocate(kPageSize));
100 ASSERT_TRUE(memory);
101 EXPECT_EQ(0U, reinterpret_cast<uint64_t>(memory->Memory()) % kPageSize);
102 WriteToDiscardableAshmemChunk(memory.get(), kPageSize);
106 scoped_ptr<DiscardableAshmemChunk> memory(allocator_.Allocate(kPageSize));
107 // Extra allocation that prevents the region from being deleted when |memory|
111 ASSERT_TRUE(memory);
112 void* const address = memory->Memory();
113 memory->Unlock(); // Tests that the reused chunk is being locked correctly.
114 memory.reset();
115 memory = allocator_.Allocate(kPageSize);
116 ASSERT_TRUE(memory);
118 EXPECT_EQ(address, memory->Memory());
119 WriteToDiscardableAshmemChunk(memory.get(), kPageSize);
124 scoped_ptr<DiscardableAshmemChunk> memory(allocator_.Allocate(kPageSize));
125 ASSERT_TRUE(memory);
127 *static_cast<int*>(memory->Memory()) = kMagic;
128 memory.reset();
131 memory = allocator_.Allocate(kPageSize);
132 ASSERT_TRUE(memory);
133 EXPECT_NE(kMagic, *static_cast<const int*>(memory->Memory()));
146 void* const address_3 = memory3->Memory();
153 EXPECT_EQ(address_3, memory1->Memory());
166 void* const memory1_address = memory1->Memory();
173 EXPECT_EQ(memory1_address, memory1->Memory());
183 void* const memory1_address = memory1->Memory();
191 static_cast<const char*>(memory2->Memory()),
202 void* const memory1_address = memory1->Memory();
215 static_cast<const char*>(memory2->Memory()),
238 *static_cast<int*>(memory2->Memory()) = kMagic;
242 EXPECT_NE(kMagic, *static_cast<int*>(memory2->Memory()));
253 void* const address = memory_2->Memory();
258 EXPECT_EQ(address, memory_2->Memory());
263 EXPECT_EQ(static_cast<char*>(address) + size, memory_3->Memory());
283 EXPECT_EQ(memory3->Memory(), static_cast<char*>(memory1->Memory()) + size);
314 EXPECT_EQ(memory3->Memory(),
315 static_cast<const char*>(memory2->Memory()) + kPageSize);