| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -191,7 +191,7 @@ internal static void Shutdown() | |||
| 191 | 191 | Instance.started = false; | |
| 192 | 192 | } | |
| 193 | 193 | ||
| 194 | - internal nint DisposeAll() | ||
| 194 | + internal nint DisposeAll(bool disposeObj = true, bool disposeDerived = true, bool disposeBuffer = true) | ||
| 195 | 195 | { | |
| 196 | 196 | if (_objQueue.IsEmpty && _derivedQueue.IsEmpty && _bufferQueue.IsEmpty) | |
| 197 | 197 | return 0; | |
@@ -216,7 +216,7 @@ internal nint DisposeAll() | |||
| 216 | 216 | ||
| 217 | 217 | try | |
| 218 | 218 | { | |
| 219 | - while (!_objQueue.IsEmpty) | ||
| 219 | + if (disposeObj) while (!_objQueue.IsEmpty) | ||
| 220 | 220 | { | |
| 221 | 221 | if (!_objQueue.TryDequeue(out var obj)) | |
| 222 | 222 | continue; | |
@@ -240,7 +240,7 @@ internal nint DisposeAll() | |||
| 240 | 240 | } | |
| 241 | 241 | } | |
| 242 | 242 | ||
| 243 | - while (!_derivedQueue.IsEmpty) | ||
| 243 | + if (disposeDerived) while (!_derivedQueue.IsEmpty) | ||
| 244 | 244 | { | |
| 245 | 245 | if (!_derivedQueue.TryDequeue(out var derived)) | |
| 246 | 246 | continue; | |
@@ -258,7 +258,7 @@ internal nint DisposeAll() | |||
| 258 | 258 | collected++; | |
| 259 | 259 | } | |
| 260 | 260 | ||
| 261 | - while (!_bufferQueue.IsEmpty) | ||
| 261 | + if (disposeBuffer) while (!_bufferQueue.IsEmpty) | ||
| 262 | 262 | { | |
| 263 | 263 | if (!_bufferQueue.TryDequeue(out var buffer)) | |
| 264 | 264 | continue; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -278,7 +278,8 @@ internal static void Shutdown() | |||
| 278 | 278 | ClearClrModules(); | |
| 279 | 279 | RemoveClrRootModule(); | |
| 280 | 280 | ||
| 281 | - TryCollectingGarbage(MaxCollectRetriesOnShutdown, forceBreakLoops: true); | ||
| 281 | + TryCollectingGarbage(MaxCollectRetriesOnShutdown, forceBreakLoops: true, | ||
| 282 | + obj: true, derived: false, buffer: false); | ||
| 282 | 283 | ||
| 283 | 284 | NullGCHandles(ExtensionType.loadedExtensions); | |
| 284 | 285 | ClassManager.RemoveClasses(); | |
@@ -329,7 +330,8 @@ internal static void Shutdown() | |||
| 329 | 330 | ||
| 330 | 331 | const int MaxCollectRetriesOnShutdown = 20; | |
| 331 | 332 | internal static int _collected; | |
| 332 | - static bool TryCollectingGarbage(int runs, bool forceBreakLoops) | ||
| 333 | + static bool TryCollectingGarbage(int runs, bool forceBreakLoops, | ||
| 334 | + bool obj = true, bool derived = true, bool buffer = true) | ||
| 333 | 335 | { | |
| 334 | 336 | if (runs <= 0) throw new ArgumentOutOfRangeException(nameof(runs)); | |
| 335 | 337 | ||
@@ -342,7 +344,9 @@ static bool TryCollectingGarbage(int runs, bool forceBreakLoops) | |||
| 342 | 344 | GC.Collect(); | |
| 343 | 345 | GC.WaitForPendingFinalizers(); | |
| 344 | 346 | pyCollected += PyGC_Collect(); | |
| 345 | - pyCollected += Finalizer.Instance.DisposeAll(); | ||
| 347 | + pyCollected += Finalizer.Instance.DisposeAll(disposeObj: obj, | ||
| 348 | + disposeDerived: derived, | ||
| 349 | + disposeBuffer: buffer); | ||
| 346 | 350 | } | |
| 347 | 351 | if (Volatile.Read(ref _collected) == 0 && pyCollected == 0) | |
| 348 | 352 | { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments