@@ -99,17 +99,11 @@ class MemoryManager{
99
99
100
100
private int $ garbageCollectionPeriod ;
101
101
private int $ garbageCollectionTicker = 0 ;
102
- private bool $ garbageCollectionTrigger ;
103
- private bool $ garbageCollectionAsync ;
104
102
105
103
private int $ cycleCollectionThreshold = self ::GC_THRESHOLD_DEFAULT ;
106
104
private int $ cycleCollectionTimeTotalNs = 0 ;
107
105
108
106
private int $ lowMemChunkRadiusOverride ;
109
- private bool $ lowMemChunkGC ;
110
-
111
- private bool $ lowMemDisableChunkCache ;
112
- private bool $ lowMemClearWorldCache ;
113
107
114
108
private bool $ dumpWorkers = true ;
115
109
@@ -157,14 +151,8 @@ private function init(ServerConfigGroup $config) : void{
157
151
$ this ->continuousTriggerRate = $ config ->getPropertyInt (Yml::MEMORY_CONTINUOUS_TRIGGER_RATE , self ::DEFAULT_CONTINUOUS_TRIGGER_RATE );
158
152
159
153
$ this ->garbageCollectionPeriod = $ config ->getPropertyInt (Yml::MEMORY_GARBAGE_COLLECTION_PERIOD , self ::DEFAULT_TICKS_PER_GC );
160
- $ this ->garbageCollectionTrigger = $ config ->getPropertyBool (Yml::MEMORY_GARBAGE_COLLECTION_LOW_MEMORY_TRIGGER , true );
161
- $ this ->garbageCollectionAsync = $ config ->getPropertyBool (Yml::MEMORY_GARBAGE_COLLECTION_COLLECT_ASYNC_WORKER , true );
162
154
163
155
$ this ->lowMemChunkRadiusOverride = $ config ->getPropertyInt (Yml::MEMORY_MAX_CHUNKS_CHUNK_RADIUS , 4 );
164
- $ this ->lowMemChunkGC = $ config ->getPropertyBool (Yml::MEMORY_MAX_CHUNKS_TRIGGER_CHUNK_COLLECT , true );
165
-
166
- $ this ->lowMemDisableChunkCache = $ config ->getPropertyBool (Yml::MEMORY_WORLD_CACHES_DISABLE_CHUNK_CACHE , true );
167
- $ this ->lowMemClearWorldCache = $ config ->getPropertyBool (Yml::MEMORY_WORLD_CACHES_LOW_MEMORY_TRIGGER , true );
168
156
169
157
$ this ->dumpWorkers = $ config ->getPropertyBool (Yml::MEMORY_MEMORY_DUMP_DUMP_ASYNC_WORKER , true );
170
158
}
@@ -177,8 +165,11 @@ public function getGlobalMemoryLimit() : int{
177
165
return $ this ->globalMemoryLimit ;
178
166
}
179
167
168
+ /**
169
+ * @deprecated
170
+ */
180
171
public function canUseChunkCache () : bool {
181
- return !$ this ->lowMemory || ! $ this -> lowMemDisableChunkCache ;
172
+ return !$ this ->lowMemory ;
182
173
}
183
174
184
175
/**
@@ -194,26 +185,19 @@ public function getViewDistance(int $distance) : int{
194
185
public function trigger (int $ memory , int $ limit , bool $ global = false , int $ triggerCount = 0 ) : void {
195
186
$ this ->logger ->debug (sprintf ("%sLow memory triggered, limit %gMB, using %gMB " ,
196
187
$ global ? "Global " : "" , round (($ limit / 1024 ) / 1024 , 2 ), round (($ memory / 1024 ) / 1024 , 2 )));
197
- if ($ this ->lowMemClearWorldCache ){
198
- foreach ($ this ->server ->getWorldManager ()->getWorlds () as $ world ){
199
- $ world ->clearCache (true );
200
- }
201
- ChunkCache::pruneCaches ();
188
+ foreach ($ this ->server ->getWorldManager ()->getWorlds () as $ world ){
189
+ $ world ->clearCache (true );
202
190
}
191
+ ChunkCache::pruneCaches ();
203
192
204
- if ($ this ->lowMemChunkGC ){
205
- foreach ($ this ->server ->getWorldManager ()->getWorlds () as $ world ){
206
- $ world ->doChunkGarbageCollection ();
207
- }
193
+ foreach ($ this ->server ->getWorldManager ()->getWorlds () as $ world ){
194
+ $ world ->doChunkGarbageCollection ();
208
195
}
209
196
210
197
$ ev = new LowMemoryEvent ($ memory , $ limit , $ global , $ triggerCount );
211
198
$ ev ->call ();
212
199
213
- $ cycles = 0 ;
214
- if ($ this ->garbageCollectionTrigger ){
215
- $ cycles = $ this ->triggerGarbageCollector ();
216
- }
200
+ $ cycles = $ this ->triggerGarbageCollector ();
217
201
218
202
$ this ->logger ->debug (sprintf ("Freed %gMB, $ cycles cycles " , round (($ ev ->getMemoryFreed () / 1024 ) / 1024 , 2 )));
219
203
}
@@ -289,14 +273,12 @@ public function check() : void{
289
273
public function triggerGarbageCollector () : int {
290
274
Timings::$ garbageCollector ->startTiming ();
291
275
292
- if ($ this ->garbageCollectionAsync ){
293
- $ pool = $ this ->server ->getAsyncPool ();
294
- if (($ w = $ pool ->shutdownUnusedWorkers ()) > 0 ){
295
- $ this ->logger ->debug ("Shut down $ w idle async pool workers " );
296
- }
297
- foreach ($ pool ->getRunningWorkers () as $ i ){
298
- $ pool ->submitTaskToWorker (new GarbageCollectionTask (), $ i );
299
- }
276
+ $ pool = $ this ->server ->getAsyncPool ();
277
+ if (($ w = $ pool ->shutdownUnusedWorkers ()) > 0 ){
278
+ $ this ->logger ->debug ("Shut down $ w idle async pool workers " );
279
+ }
280
+ foreach ($ pool ->getRunningWorkers () as $ i ){
281
+ $ pool ->submitTaskToWorker (new GarbageCollectionTask (), $ i );
300
282
}
301
283
302
284
$ cycles = gc_collect_cycles ();
0 commit comments