@@ -87,6 +87,7 @@ class ChunkPool {
8787 // Our four static pools
8888 static constexpr int _num_pools = 4 ;
8989 static ChunkPool _pools[_num_pools];
90+ volatile static bool _suspend_cleaning;
9091
9192 Chunk* _first;
9293 const size_t _size; // (inner payload) size of the chunks this pool serves
@@ -135,6 +136,7 @@ class ChunkPool {
135136 ChunkPool (size_t size) : _first(nullptr ), _size(size) {}
136137
137138 static void clean () {
139+ if (_suspend_cleaning) return ;
138140 NativeHeapTrimmer::SuspendMark sm (" chunk pool cleaner" );
139141 for (int i = 0 ; i < _num_pools; i++) {
140142 _pools[i].prune ();
@@ -144,6 +146,9 @@ class ChunkPool {
144146 // Returns an initialized and null-terminated Chunk of requested size
145147 static Chunk* allocate_chunk (Arena* arena, size_t length, AllocFailType alloc_failmode);
146148 static void deallocate_chunk (Chunk* p);
149+ static void set_suspend_cleaning (bool suspend) {
150+ _suspend_cleaning = suspend;
151+ }
147152};
148153
149154static bool on_compiler_thread () {
@@ -230,6 +235,7 @@ void ChunkPool::deallocate_chunk(Chunk* c) {
230235}
231236
232237ChunkPool ChunkPool::_pools[] = { Chunk::size, Chunk::medium_size, Chunk::init_size, Chunk::tiny_size };
238+ volatile bool ChunkPool::_suspend_cleaning = false ;
233239
234240class ChunkPoolCleaner : public PeriodicTask {
235241 static const int cleaning_interval = 5000 ; // cleaning interval in ms
@@ -241,6 +247,10 @@ class ChunkPoolCleaner : public PeriodicTask {
241247 }
242248};
243249
250+ void Arena::suspend_chunk_pool_cleaning (bool suspend) {
251+ ChunkPool::set_suspend_cleaning (suspend);
252+ }
253+
244254void Arena::start_chunk_pool_cleaner_task () {
245255#ifdef ASSERT
246256 static bool task_created = false ;
0 commit comments