overlaytopleft/games-fps/gzdoom/files/0005-fixed-GC-FullGC-not-collecting-everything-anymore.patch

71 lines
1.9 KiB
Diff
Raw Normal View History

From 91930dfe53d6ca1432c9e58cb108124e5b3ea5b0 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Mon, 5 Dec 2022 12:29:03 +0100
Subject: [PATCH 05/51] - fixed GC::FullGC not collecting everything anymore.
With the delayed handling of internal references of destroyed objects the function now returned without making sure that it really got everything.
Repeating until it cannot delete anything new anymore makes it work again as intended.
---
src/common/objects/dobjgc.cpp | 40 ++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/src/common/objects/dobjgc.cpp b/src/common/objects/dobjgc.cpp
index 34199efff..9baffc3a3 100644
--- a/src/common/objects/dobjgc.cpp
+++ b/src/common/objects/dobjgc.cpp
@@ -550,28 +550,34 @@ void Step()
void FullGC()
{
- if (State <= GCS_Propagate)
+ bool ContinueCheck = true;
+ while (ContinueCheck)
{
- // Reset sweep mark to sweep all elements (returning them to white)
- SweepPos = &Root;
- // Reset other collector lists
- Gray = nullptr;
- State = GCS_Sweep;
- }
- // Finish any pending GC stages
- while (State != GCS_Pause)
- {
- SingleStep();
- }
- // Loop until everything that can be destroyed and freed is
- do
- {
- MarkRoot();
+ ContinueCheck = false;
+ if (State <= GCS_Propagate)
+ {
+ // Reset sweep mark to sweep all elements (returning them to white)
+ SweepPos = &Root;
+ // Reset other collector lists
+ Gray = nullptr;
+ State = GCS_Sweep;
+ }
+ // Finish any pending GC stages
while (State != GCS_Pause)
{
SingleStep();
}
- } while (HadToDestroy);
+ // Loop until everything that can be destroyed and freed is
+ do
+ {
+ MarkRoot();
+ while (State != GCS_Pause)
+ {
+ SingleStep();
+ }
+ ContinueCheck |= HadToDestroy;
+ } while (HadToDestroy);
+ }
}
//==========================================================================
--
2.39.3