Clean-up heap spaces.
We now use the CMS collector instead of the semispace collector when
the phone is booting. We still perform compaction during the zygote
space creation. This reduces time spent in GC by ~2s during boot
and doesn't affect zygote space size.
Changed the space creation logic to create the temp space when a
background transition occurs.
Added a flag to each space which is true if you are allowed to
move objects that are within this space.
Removed SwapSemiSpaces call from the semi space collector, it is now
the job of the caller to do this with threads suspended. This
simplifies the logic in the zygote compaction / heap transition code
since these do not copy from one semispace to another.
Added Space::Clear to RosAllocSpace and DlMallocSpace. This greatly
simplifies the code used for collector transitions.
Time spent in GC creating zygote space:
Before: 3.4s, After: 1.28s
No change in zygote space size.
Bug: 13878055
Change-Id: I700348ab7d5bf3aa537c0cd70c0fed09aa4b0623
diff --git a/runtime/gc/space/malloc_space.h b/runtime/gc/space/malloc_space.h
index fbcee5f..dd4e5d4 100644
--- a/runtime/gc/space/malloc_space.h
+++ b/runtime/gc/space/malloc_space.h
@@ -114,7 +114,8 @@
void SetGrowthLimit(size_t growth_limit);
virtual MallocSpace* CreateInstance(const std::string& name, MemMap* mem_map, void* allocator,
- byte* begin, byte* end, byte* limit, size_t growth_limit) = 0;
+ byte* begin, byte* end, byte* limit, size_t growth_limit,
+ bool can_move_objects) = 0;
// Splits ourself into a zygote space and new malloc space which has our unused memory. When true,
// the low memory mode argument specifies that the heap wishes the created space to be more
@@ -127,9 +128,14 @@
// Returns the class of a recently freed object.
mirror::Class* FindRecentFreedObject(const mirror::Object* obj);
+ bool CanMoveObjects() const OVERRIDE {
+ return can_move_objects_;
+ }
+
protected:
MallocSpace(const std::string& name, MemMap* mem_map, byte* begin, byte* end,
- byte* limit, size_t growth_limit, bool create_bitmaps = true);
+ byte* limit, size_t growth_limit, bool create_bitmaps, bool can_move_objects,
+ size_t starting_size, size_t initial_size);
static MemMap* CreateMemMap(const std::string& name, size_t starting_size, size_t* initial_size,
size_t* growth_limit, size_t* capacity, byte* requested_begin);
@@ -167,6 +173,13 @@
// one time by a call to ClearGrowthLimit.
size_t growth_limit_;
+ // True if objects in the space are movable.
+ const bool can_move_objects_;
+
+ // Starting and initial sized, used when you reset the space.
+ const size_t starting_size_;
+ const size_t initial_size_;
+
private:
static void SweepCallback(size_t num_ptrs, mirror::Object** ptrs, void* arg)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);