Checking for NULL with IsValidLowLevel()?

Hello!
How safe is it now to use IsValidLowLevel() to check for NULL?

I found an explanation on the Internet from 2014, where it says that before checking MyObject->IsValidLowLevel(), you need to check MyObject!=NULL, otherwise it will crash (Forum link).

But I wrote the following code for testing:
UObject* MyObject = NULL;
if (!MyObjec->IsValidLowLevel())GEngine->AddOnScreenDebugMessage(-1, 10, FColor::Yellow, “NotValid”);
I have no problems with this, the text “NotValid” is displayed on the screen without errors.

In what cases can the game crash when using IsValidLowLevel()?
I would be very grateful if you explain the situation to me :slight_smile:

It never makes any sense to use IsValidLowLevel() in game code.

The only one you should use in game code is IsValid(), because it also checks if the object is pending being GC’d.

IsValidLowLevel() is a much more expensive, thorough check that gamecode shouldn’t ever need to perform.

1 Like