Unreal editor freezing and then crashing after adding GetValidWords() Function

Hello everyone

I have been following the video lesson “TArray Functions Adding and Removing” from the game bulls and cows presented on the course “Unreal Engine C++ Developer: Learn C++ and Make Video Games”.

After adding the exact same code presented in the lesson for the GetValidWords() function my Unreal editor compiles correctly. However when I hit the play button it freezes for a moment and then after a while it presents a crash report saying the following:

Assertion failed: [File:D:\Build++UE4\Sync\Engine\Source\Runtime\Core\Private\GenericPlatform\GenericPlatformMemory.cpp] [Line: 212] Ran out of memory allocating 16776891792 bytes with alignment 0

I do know that the problem is provoked by this new function but I’m not sure what can I do about it. Any suggestion is much appreciated. Thanks in advance and here is my code and the crash report screenshot:

Crash report 1

Crash report 2

BullCowCartridge.cpp - part 1

BullCowCartridge.cpp - part 2

HiddenWordList.h

BullCowCartridge.h

Well that says you’re running out of memory.

As it’s a global variable you don’t need to pass the array into the function, just use it directly. I would also create a member variable to hold the valid words instead of getting the list of valid words multiple times.

void UBullCowCartridge::GetValidWords() 
{
    for (const FString& Word : GameWords)
    {
        if (Word.Len() >= 4 && Word.Len() <= 8)
        {
            Isograms.Emplace(Word);
        }
    }
}
void UBullCowCartridge::BeginPlay() 
{
    Super::BeginPlay();
    GetValidWords(); // do once at the beginning.
    // rest of the function.
}
1 Like

Hello DanM

Thank you very much for your advice. Indeed the problem was with code line 21 that can be seen in the image BullCowCartridge.cpp - part1.

I have a TArray of 323 isograms and I was trying to print all of those words after checking if they are isograms on the game terminal. Therefore, Unreal tells me that the terminal is running out of memory. So, after removing that PrintLine my code works correctly.

Also, with your advice the code is more efficient and readable. Thank you so much

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms