Lines Matching refs:space
35 namespace space {
42 void AddSpace(ContinuousSpace* space, bool revoke = true) {
49 ScopedSuspendAll ssa("Add image space");
50 heap->AddSpace(space);
52 heap->SetSpaceAsDefault(space);
68 mirror::Object* Alloc(space::MallocSpace* alloc_space,
88 mirror::Object* AllocWithGrowth(space::MallocSpace* alloc_space,
130 void SizeFootPrintGrowthLimitAndTrimBody(MallocSpace* space, intptr_t object_size,
141 void SpaceTest<Super>::SizeFootPrintGrowthLimitAndTrimBody(MallocSpace* space,
151 // The space's footprint equals amount of resources requested from system
152 size_t footprint = space->GetFootprint();
154 // The space must at least have its book keeping allocated
160 // space's size shouldn't exceed the initial size
161 EXPECT_LE(space->Size(), growth_limit);
163 // this invariant should always hold or else the space has grown to be larger than what the
164 // space believes its size is (which will break invariants)
165 EXPECT_GE(space->Size(), footprint);
167 // Fill the space with lots of small objects up to the growth limit
171 size_t amount_allocated = 0; // amount of space allocated
195 object.Assign(Alloc(space, self, alloc_size, &bytes_allocated, nullptr,
198 object.Assign(AllocWithGrowth(space, self, alloc_size, &bytes_allocated, nullptr,
201 footprint = space->GetFootprint();
202 EXPECT_GE(space->Size(), footprint); // invariant
205 size_t allocation_size = space->AllocationSize(object.Get(), nullptr);
223 CHECK_NE(last_object, 0u); // we should have filled the space
229 EXPECT_LE(space->Size(), growth_limit);
233 EXPECT_GE(space->Size(), amount_allocated);
240 // Give the space a haircut.
241 space->Trim();
245 footprint = space->GetFootprint();
249 EXPECT_GE(space->Size(), amount_allocated);
250 EXPECT_LE(space->Size(), growth_limit);
262 size_t allocation_size = space->AllocationSize(object, nullptr);
268 space->Free(self, object);
271 footprint = space->GetFootprint();
272 EXPECT_GE(space->Size(), footprint); // invariant
278 // The space has become empty here before allocating a large object
284 space->RevokeAllThreadLocalBuffers();
293 large_object.Assign(Alloc(space, self, three_quarters_space, &bytes_allocated, nullptr,
296 large_object.Assign(AllocWithGrowth(space, self, three_quarters_space, &bytes_allocated,
302 footprint = space->GetFootprint();
304 EXPECT_GE(space->Size(), footprint);
305 EXPECT_LE(space->Size(), growth_limit);
308 space->Free(self, large_object.Assign(nullptr));
311 footprint = space->GetFootprint();
313 EXPECT_GE(space->Size(), footprint);
314 EXPECT_LE(space->Size(), growth_limit);
327 MallocSpace* space(create_space("test", initial_size, growth_limit, capacity, nullptr));
328 ASSERT_TRUE(space != nullptr);
331 EXPECT_EQ(space->Capacity(), growth_limit);
332 EXPECT_EQ(space->NonGrowthLimitCapacity(), capacity);
334 // Make space findable to the heap, will also delete space when runtime is cleaned up
335 AddSpace(space);
339 SizeFootPrintGrowthLimitAndTrimBody(space, object_size, 1, initial_size);
340 SizeFootPrintGrowthLimitAndTrimBody(space, object_size, 2, growth_limit);
342 space->ClearGrowthLimit();
343 EXPECT_EQ(space->Capacity(), capacity);
344 SizeFootPrintGrowthLimitAndTrimBody(space, object_size, 3, capacity);
388 } // namespace space