[Crash] Invalid Object in GC, after ForceGarbageCollection(true)

#Environment

Editor is closed, not even loaded, running independent game instance, not packaged

#Repro

Spawn bunch of characters

“delete” them by moving them below the Killz of 0,0,0 (or whatever it is for your map)

spawn some more characters, from your Charcter blueprint

You never call DestroyActor, you just move the Characters below the KillZ and let the engine do the rest :slight_smile:

(Why? see below)

Then use ObjectIterator to iterate overall actors of your spawned Character class and get their names

or try just calling

GetWorld()->ForceGarbageCollection(true);

repeat

When I do this several times, as per my in-game editor, I get this crash.

Invalid object in GC: 0x00000000c2b3fffc, ReferencingObject: VictorySkelBP_C /Game/Maps/Victory.TheWorld:PersistentLevel.VictorySkelBP_C_76, TokenIndex: 15

Address = 0xfd269e5d (filename not found) [in C:\Windows\system32\KERNELBASE.dll]
Address = 0xd9ee1a1c (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Core.dll]
Address = 0xd9dec8b2 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Core.dll]
Address = 0xe37e4e86 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-CoreUObject.dll]
Address = 0xe37cf061 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-CoreUObject.dll]
Address = 0xd9d19856 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Core.dll]
Address = 0xd9d1999d (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Core.dll]
Address = 0xd9d221ab (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Core.dll]
Address = 0xd9ee0c69 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Core.dll]
Address = 0xd9edd1b1 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Core.dll]
Address = 0x7726652d (filename not found) [in C:\Windows\system32\kernel32.dll]

#ObjectIterator Checks

I am doing as many checks as I can think of to verify the integrity of the Actor!!

What else can I do?

//Evolvers
for ( TObjectIterator Itr; Itr; ++Itr )
{
	//Evolver is Valid?
	if( ! Itr->IsValidLowLevel()) 	continue;
	if(Itr->IsPendingKill()) 			continue;
	if(  !  Itr->bActorInitialized)	continue;
	//~~~~~~~~~~~~~~~~~~~~~~~
	
	Itr->SERVER_SetGameMode(EnteringGameMode);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#Full Purge

The full purge of the GC seems to be the more related issue in this particular crash.

I do need to be able to do this though

And in this example I am not doing anything directly!
I am forcing the engine to handle the deleting of the characters that are below the KillZ


#Related But Distinct

This thread is related to my other thread,

https://rocket.unrealengine.com/questions/14243/crash-movedcomponent-none-not-initialized-deleteme.html

but this is an alternative solution where I am forcing the engine to handle the deleting of the Characters using its own method

But when I do the above and then call

GetWorld()->ForceGarbageCollection(true);

the crash happens

#Additional Testing

After doing additional testing with just sending actors down to the KillZ (forcing the engine to delete them in its own way)

and then spawning more actors

and NOT even calling Garbage Collection

I am still getting a crash

but this crash had no message at all

#Something is Wrong

Something is wrong with the engine’s ability to let you spawn characters, delete them, spawn more, and then call garbage collection, at least the way I am doing it using GetWorld->SpawnActor

and using a Character blueprint as a the spawn class.

Currently I am faced with having to make a Character Pool system instead of deleting Characters, and just re-using them, without ever even attempting to delete them so that there is no crash.

#Static Mesh Actors Good

I have no issues spawning, deleting, and then spawning more Static Mesh Actors, also using a blueprint of my custom Static Mesh Actor class.

#ActorIterator

Switching to using ActorIterator did not cause any improvement,

I switched hoping the ObjectIterator was just picking up on recently deleted actors somehow

But the crash remains

Hi ,

If possible, would you be able to make a fresh project and solely re-create the conditions under which this crash occurs? If so, we would be interested in accessing the project for testing.

Cheers

Any news on that issue? It’s happening to me right now.

Hey CharlesM-

The original issue here is over two years old. With the changes that have gone into the engine, there has been no indication of this occurring. Please create a new post with as much detail about the problem you’re having to help track and investigate your issue.

Cheers