1cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi/*
2cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi * Copyright (C) 2013 The Android Open Source Project
3cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi *
4cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi * Licensed under the Apache License, Version 2.0 (the "License");
5cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi * you may not use this file except in compliance with the License.
6cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi * You may obtain a copy of the License at
7cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi *
8cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi *      http://www.apache.org/licenses/LICENSE-2.0
9cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi *
10cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi * Unless required by applicable law or agreed to in writing, software
11cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi * distributed under the License is distributed on an "AS IS" BASIS,
12cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi * See the License for the specific language governing permissions and
14cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi * limitations under the License.
15cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi */
16cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
17cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi#ifndef ART_RUNTIME_GC_SPACE_MALLOC_SPACE_H_
18cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi#define ART_RUNTIME_GC_SPACE_MALLOC_SPACE_H_
19cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
20cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi#include "space.h"
21cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
22cf7f19135f0e273f7b0136315633c2abfc715343Ian Rogers#include <ostream>
231e13374baf7dfaf442ffbf9809c37c131d681eafEvgenii Stepanov#include "base/memory_tool.h"
247cb7bbcfffb2716ef8d68ecb747954ec42c4bdc5Hiroshi Yamauchi
25cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchinamespace art {
26cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchinamespace gc {
27cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
28cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchinamespace collector {
292ffb703bf431d74326c88266b4ddaf225eb3c6adIgor Murashkinclass MarkSweep;
30cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi}  // namespace collector
31cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
32cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchinamespace space {
33cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
34a1602f28c0e3127ad511712d4b08db89737ae901Mathieu Chartierclass ZygoteSpace;
35a1602f28c0e3127ad511712d4b08db89737ae901Mathieu Chartier
36cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi// A common parent of DlMallocSpace and RosAllocSpace.
37cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchiclass MallocSpace : public ContinuousMemMapAllocSpace {
38cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi public:
39cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  typedef void(*WalkCallback)(void *start, void *end, size_t num_bytes, void* callback_arg);
40cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
41cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  SpaceType GetType() const {
42a1602f28c0e3127ad511712d4b08db89737ae901Mathieu Chartier    return kSpaceTypeMallocSpace;
43cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  }
44cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
45cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // Allocate num_bytes allowing the underlying space to grow.
466fac447555dc94a935b78198479cce645c837b89Ian Rogers  virtual mirror::Object* AllocWithGrowth(Thread* self, size_t num_bytes,
474460a84be92b5a94ecfb5c650aef4945ab849c93Hiroshi Yamauchi                                          size_t* bytes_allocated, size_t* usable_size,
484460a84be92b5a94ecfb5c650aef4945ab849c93Hiroshi Yamauchi                                          size_t* bytes_tl_bulk_allocated) = 0;
496fac447555dc94a935b78198479cce645c837b89Ian Rogers  // Allocate num_bytes without allowing the underlying space to grow.
506fac447555dc94a935b78198479cce645c837b89Ian Rogers  virtual mirror::Object* Alloc(Thread* self, size_t num_bytes, size_t* bytes_allocated,
514460a84be92b5a94ecfb5c650aef4945ab849c93Hiroshi Yamauchi                                size_t* usable_size, size_t* bytes_tl_bulk_allocated) = 0;
522cebb24bfc3247d3e9be138a3350106737455918Mathieu Chartier  // Return the storage space required by obj. If usable_size isn't null then it is set to the
536fac447555dc94a935b78198479cce645c837b89Ian Rogers  // amount of the storage space that may be used by obj.
546fac447555dc94a935b78198479cce645c837b89Ian Rogers  virtual size_t AllocationSize(mirror::Object* obj, size_t* usable_size) = 0;
55ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers  virtual size_t Free(Thread* self, mirror::Object* ptr)
56bdf7f1c3ab65ccb70f62db5ab31dba060632d458Andreas Gampe      REQUIRES_SHARED(Locks::mutator_lock_) = 0;
57ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers  virtual size_t FreeList(Thread* self, size_t num_ptrs, mirror::Object** ptrs)
58bdf7f1c3ab65ccb70f62db5ab31dba060632d458Andreas Gampe      REQUIRES_SHARED(Locks::mutator_lock_) = 0;
59cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
604460a84be92b5a94ecfb5c650aef4945ab849c93Hiroshi Yamauchi  // Returns the maximum bytes that could be allocated for the given
614460a84be92b5a94ecfb5c650aef4945ab849c93Hiroshi Yamauchi  // size in bulk, that is the maximum value for the
624460a84be92b5a94ecfb5c650aef4945ab849c93Hiroshi Yamauchi  // bytes_allocated_bulk out param returned by MallocSpace::Alloc().
634460a84be92b5a94ecfb5c650aef4945ab849c93Hiroshi Yamauchi  virtual size_t MaxBytesBulkAllocatedFor(size_t num_bytes) = 0;
644460a84be92b5a94ecfb5c650aef4945ab849c93Hiroshi Yamauchi
65cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi#ifndef NDEBUG
66cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  virtual void CheckMoreCoreForPrecondition() {}  // to be overridden in the debug build.
67cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi#else
68cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  void CheckMoreCoreForPrecondition() {}  // no-op in the non-debug build.
69cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi#endif
70cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
71cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  void* MoreCore(intptr_t increment);
72cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
73cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // Hands unused pages back to the system.
74cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  virtual size_t Trim() = 0;
75cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
76cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // Perform a mspace_inspect_all which calls back for each allocation chunk. The chunk may not be
77cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // in use, indicated by num_bytes equaling zero.
78cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  virtual void Walk(WalkCallback callback, void* arg) = 0;
79cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
80cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // Returns the number of bytes that the space has currently obtained from the system. This is
81cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // greater or equal to the amount of live data in the space.
82cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  virtual size_t GetFootprint() = 0;
83cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
84cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // Returns the number of bytes that the heap is allowed to obtain from the system via MoreCore.
85cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  virtual size_t GetFootprintLimit() = 0;
86cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
87cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // Set the maximum number of bytes that the heap is allowed to obtain from the system via
88cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // MoreCore. Note this is used to stop the mspace growing beyond the limit to Capacity. When
89cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // allocations fail we GC before increasing the footprint limit and allowing the mspace to grow.
90cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  virtual void SetFootprintLimit(size_t limit) = 0;
91cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
92cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // Removes the fork time growth limit on capacity, allowing the application to allocate up to the
93cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // maximum reserved size of the heap.
94cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  void ClearGrowthLimit() {
95cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi    growth_limit_ = NonGrowthLimitCapacity();
96cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  }
97cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
98cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // Override capacity so that we only return the possibly limited capacity
99cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  size_t Capacity() const {
100cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi    return growth_limit_;
101cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  }
102cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
103cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // The total amount of memory reserved for the alloc space.
104cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  size_t NonGrowthLimitCapacity() const {
105cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi    return GetMemMap()->Size();
106cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  }
107cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
108379d09fe3c3feb7c2a2fb5a3623689b5ace7e79bMathieu Chartier  // Change the non growth limit capacity by shrinking or expanding the map. Currently, only
109379d09fe3c3feb7c2a2fb5a3623689b5ace7e79bMathieu Chartier  // shrinking is supported.
110379d09fe3c3feb7c2a2fb5a3623689b5ace7e79bMathieu Chartier  void ClampGrowthLimit();
111379d09fe3c3feb7c2a2fb5a3623689b5ace7e79bMathieu Chartier
112cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  void Dump(std::ostream& os) const;
113cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
114cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  void SetGrowthLimit(size_t growth_limit);
115cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
116d7576328811e5103e99d31f834a857522cc1463fAndreas Gampe  virtual MallocSpace* CreateInstance(MemMap* mem_map, const std::string& name, void* allocator,
117d7576328811e5103e99d31f834a857522cc1463fAndreas Gampe                                      uint8_t* begin, uint8_t* end, uint8_t* limit,
118d7576328811e5103e99d31f834a857522cc1463fAndreas Gampe                                      size_t growth_limit, bool can_move_objects) = 0;
119cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
120a1602f28c0e3127ad511712d4b08db89737ae901Mathieu Chartier  // Splits ourself into a zygote space and new malloc space which has our unused memory. When true,
121a1602f28c0e3127ad511712d4b08db89737ae901Mathieu Chartier  // the low memory mode argument specifies that the heap wishes the created space to be more
122a1602f28c0e3127ad511712d4b08db89737ae901Mathieu Chartier  // aggressive in releasing unused pages. Invalidates the space its called on.
123a1602f28c0e3127ad511712d4b08db89737ae901Mathieu Chartier  ZygoteSpace* CreateZygoteSpace(const char* alloc_space_name, bool low_memory_mode,
124a1602f28c0e3127ad511712d4b08db89737ae901Mathieu Chartier                                 MallocSpace** out_malloc_space) NO_THREAD_SAFETY_ANALYSIS;
125cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  virtual uint64_t GetBytesAllocated() = 0;
126cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  virtual uint64_t GetObjectsAllocated() = 0;
127cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
128cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // Returns the class of a recently freed object.
129cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  mirror::Class* FindRecentFreedObject(const mirror::Object* obj);
130cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
13131f441464c0c8f840aba37e236ad133f30308d70Mathieu Chartier  bool CanMoveObjects() const OVERRIDE {
13231f441464c0c8f840aba37e236ad133f30308d70Mathieu Chartier    return can_move_objects_;
13331f441464c0c8f840aba37e236ad133f30308d70Mathieu Chartier  }
13431f441464c0c8f840aba37e236ad133f30308d70Mathieu Chartier
1356a7824dc81aaab3cb09ced16affca72d1b1da649Mathieu Chartier  void DisableMovingObjects() {
1366a7824dc81aaab3cb09ced16affca72d1b1da649Mathieu Chartier    can_move_objects_ = false;
1376a7824dc81aaab3cb09ced16affca72d1b1da649Mathieu Chartier  }
1386a7824dc81aaab3cb09ced16affca72d1b1da649Mathieu Chartier
139cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi protected:
14013735955f39b3b304c37d2b2840663c131262c18Ian Rogers  MallocSpace(const std::string& name, MemMap* mem_map, uint8_t* begin, uint8_t* end,
14113735955f39b3b304c37d2b2840663c131262c18Ian Rogers              uint8_t* limit, size_t growth_limit, bool create_bitmaps, bool can_move_objects,
14231f441464c0c8f840aba37e236ad133f30308d70Mathieu Chartier              size_t starting_size, size_t initial_size);
143cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
144cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  static MemMap* CreateMemMap(const std::string& name, size_t starting_size, size_t* initial_size,
14513735955f39b3b304c37d2b2840663c131262c18Ian Rogers                              size_t* growth_limit, size_t* capacity, uint8_t* requested_begin);
146cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
1476fac447555dc94a935b78198479cce645c837b89Ian Rogers  // When true the low memory mode argument specifies that the heap wishes the created allocator to
1486fac447555dc94a935b78198479cce645c837b89Ian Rogers  // be more aggressive in releasing unused pages.
149573f7d2d68e1838a0485e6b40d90c967526e00c2Hiroshi Yamauchi  virtual void* CreateAllocator(void* base, size_t morecore_start, size_t initial_size,
15026d69ffc0ebc98fbc5f316d8cd3ee6ba5b2001acHiroshi Yamauchi                                size_t maximum_size, bool low_memory_mode) = 0;
151cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
152661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8Mathieu Chartier  virtual void RegisterRecentFree(mirror::Object* ptr)
153bdf7f1c3ab65ccb70f62db5ab31dba060632d458Andreas Gampe      REQUIRES_SHARED(Locks::mutator_lock_)
15490443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier      REQUIRES(lock_);
155cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
156a8e8f9c0a8e259a807d7b99a148d14104c24209dMathieu Chartier  virtual accounting::ContinuousSpaceBitmap::SweepCallback* GetSweepCallback() {
157a1602f28c0e3127ad511712d4b08db89737ae901Mathieu Chartier    return &SweepCallback;
158a1602f28c0e3127ad511712d4b08db89737ae901Mathieu Chartier  }
159cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
160cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // Recent allocation buffer.
161cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  static constexpr size_t kRecentFreeCount = kDebugSpaces ? (1 << 16) : 0;
162cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  static constexpr size_t kRecentFreeMask = kRecentFreeCount - 1;
163cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  std::pair<const mirror::Object*, mirror::Class*> recent_freed_objects_[kRecentFreeCount];
164cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  size_t recent_free_pos_;
165cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
166cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  static size_t bitmap_index_;
167cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
168cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // Used to ensure mutual exclusion when the allocation spaces data structures are being modified.
169cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  Mutex lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
170cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
171cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // The capacity of the alloc space until such time that ClearGrowthLimit is called.
172cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // The underlying mem_map_ controls the maximum size we allow the heap to grow to. The growth
173cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // limit is a value <= to the mem_map_ capacity used for ergonomic reasons because of the zygote.
174cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // Prior to forking the zygote the heap will have a maximally sized mem_map_ but the growth_limit_
175cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // will be set to a lower value. The growth_limit_ is used as the capacity of the alloc_space_,
176cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // however, capacity normally can't vary. In the case of the growth_limit_ it can be cleared
177cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  // one time by a call to ClearGrowthLimit.
178cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  size_t growth_limit_;
179cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
18031f441464c0c8f840aba37e236ad133f30308d70Mathieu Chartier  // True if objects in the space are movable.
1816a7824dc81aaab3cb09ced16affca72d1b1da649Mathieu Chartier  bool can_move_objects_;
18231f441464c0c8f840aba37e236ad133f30308d70Mathieu Chartier
18331f441464c0c8f840aba37e236ad133f30308d70Mathieu Chartier  // Starting and initial sized, used when you reset the space.
18431f441464c0c8f840aba37e236ad133f30308d70Mathieu Chartier  const size_t starting_size_;
18531f441464c0c8f840aba37e236ad133f30308d70Mathieu Chartier  const size_t initial_size_;
18631f441464c0c8f840aba37e236ad133f30308d70Mathieu Chartier
187e5eedcb4a634246d1f912992853441f715d705ccHiroshi Yamauchi private:
188ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers  static void SweepCallback(size_t num_ptrs, mirror::Object** ptrs, void* arg)
189bdf7f1c3ab65ccb70f62db5ab31dba060632d458Andreas Gampe      REQUIRES_SHARED(Locks::mutator_lock_);
190a1602f28c0e3127ad511712d4b08db89737ae901Mathieu Chartier
191cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi  DISALLOW_COPY_AND_ASSIGN(MallocSpace);
192cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi};
193cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
194cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi}  // namespace space
195cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi}  // namespace gc
196cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi}  // namespace art
197cf58d4adf461eb9b8e84baa8019054c88cd8acc6Hiroshi Yamauchi
198e5eedcb4a634246d1f912992853441f715d705ccHiroshi Yamauchi#endif  // ART_RUNTIME_GC_SPACE_MALLOC_SPACE_H_
199