diff --git a/docs/rh-log.txt b/docs/rh-log.txt index bf41a44ac6..534f1f4cd4 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,10 @@ +September 5, 2008 +- The garbage collector now has an opportunity to step each time individual + thinkers tick, not just once every game tick. This more closely follows + the original Lua behavior. This change was made because, in cases of + extremely large and frequent memory allocations, the collector may not run + fast enough if it only has a chance to execute once per tick. + September 4, 2008 - Fixed: The "same level" dmflag did not work. - Changed the nextlevel global var to an FString. diff --git a/src/dobjgc.cpp b/src/dobjgc.cpp index ac59004e17..fedd5076d3 100644 --- a/src/dobjgc.cpp +++ b/src/dobjgc.cpp @@ -126,6 +126,8 @@ IMPLEMENT_CLASS(DSectorMarker) // EXTERNAL DATA DECLARATIONS ---------------------------------------------- +extern DThinker *NextToThink; + // PUBLIC DATA DEFINITIONS ------------------------------------------------- namespace GC @@ -327,6 +329,8 @@ static void MarkRoot() Mark(bglobal.firstthing); Mark(bglobal.body1); Mark(bglobal.body2); + // NextToThink must not be freed while thinkers are ticking. + Mark(NextToThink); // Mark soft roots. if (SoftRoots != NULL) { diff --git a/src/dthinker.cpp b/src/dthinker.cpp index ecac8933ff..36003aa98e 100644 --- a/src/dthinker.cpp +++ b/src/dthinker.cpp @@ -46,7 +46,7 @@ extern int BotWTG; IMPLEMENT_CLASS (DThinker) -static DThinker *NextToThink; +DThinker *NextToThink; FThinkerList DThinker::Thinkers[MAX_STATNUM+2]; FThinkerList DThinker::FreshThinkers[MAX_STATNUM+1]; @@ -463,6 +463,7 @@ int DThinker::TickThinkers (FThinkerList *list, FThinkerList *dest) if (!(node->ObjectFlags & OF_EuthanizeMe)) { // Only tick thinkers not scheduled for destruction node->Tick (); + GC::CheckGC(); } node = NextToThink; }