[CRASH] access violation in FMallocTBB::Free

Error occurred suddenly

Here screen with all information about crash:

Hey -

Can you provide any details about what you were doing when this crash occurred? Did this happen when working inside a blueprint/widget? Were you playing in the editor when the crash happened? The screenshot does show an issue with UE4Editor-Core.dll however the Cyrillic characters makes it difficult to understand what is being said. Could you provide a translation of what the error is saying?

I’m having the same issue. It occurs when I call delete[] on a uint8* in the destructor of a class which extends AActor

Hey DannRees-

Is the crash you’re getting specifically in FMallocTBB::Free? Can you provide the callstack from your crash as well as the setup code you’re using that causes the crash?

Yes. Here’s the call stack from VS.

 	UE4Editor-Core.dll!rml::internal::ExtMemoryPool::initTLS(void)	Unknown
>	UE4Editor-Core.dll!FMallocTBB::Free(void * Ptr) Line 109	C++
 	UE4Editor-Core.dll!FMemory::Free(void * Original) Line 49	C++
 	UE4Editor-TirGame-Win64-DebugGame.dll!operator delete[](void * Ptr) Line 6	C++
 	UE4Editor-TirGame-Win64-DebugGame.dll!ATirGamePaintableMesh::~ATirGamePaintableMesh() Line 27	C++
 	UE4Editor-TirGame-Win64-DebugGame.dll!ATirGameLandscape::~ATirGameLandscape() Line 18	C++
 	[External Code]	
 	UE4Editor-CoreUObject.dll!IncrementalPurgeGarbage(bool bUseTimeLimit, float TimeLimit) Line 1042	C++
 	UE4Editor-CoreUObject.dll!CollectGarbageInternal(EObjectFlags KeepFlags, bool bPerformFullPurge) Line 1321	C++
 	UE4Editor-CoreUObject.dll!CollectGarbage(EObjectFlags KeepFlags, bool bPerformFullPurge) Line 1341	C++
 	UE4Editor-UnrealEd.dll!UEditorEngine::EndPlayMap() Line 375	C++
 	UE4Editor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 1587	C++
 	UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 368	C++
 	UE4Editor.exe!FEngineLoop::Tick() Line 2775	C++
 	UE4Editor.exe!GuardedMain(const wchar_t * CmdLine, HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, int nCmdShow) Line 148	C++
 	UE4Editor.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow) Line 189	C++
 	[External Code]

In an FRunnable Run Method. I’m creating it like this…

uint8* pixelData = new uint8[pixels->Num()];

Then passing it onto the Actor with


The actors variable looks like this…

uint8* mDynamicColors;

And in the actors destructor I’m doing the following…

if (mDynamicColors)
	delete[] mDynamicColors;

Hey DannRees-

The issue here is the delete call. Unreal garbage collection handles deallocation and freeing of memory when an actor is destroyed. What’s happening in this case is you’re freeing the memory manually, then garbage collection attempts to free the memory since the actor is being deleted, but suddenly can’t find the array because it has already been freed. Because the engine manages its memory, using new/delete is going to cause garbage collection issues.


Oh, I was under the impression that if the variable wasn’t marked with UPROPERTY it wouldn’t be GC’d by the engine? I’ve seen a few examples of using delete in the wiki (particularly the dynamic texture tutorial which I used).

How would I dispose of the data manually? the uint8* is storing pixel data of a 2048 image and so I want to free up the memory when I no longer need it.

(example of using delete in wiki: A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums)

Additionally this Wiki says you can use new and delete

When the actor is deleted and cleaned up by garbage collection it will free the data with no need to do so manually. The answer provided by Tim in the following post explains more about GC and freeing memory: