Description

When Calling UBlueprintMapLibrary::GenericMap_Find with a non-existent key, the function construct the default structure in-place on the given pointer without destroying the object.
This behavior causes a memory leak.

The following fix works :

bool UBlueprintMapLibrary::GenericMap_Find(const void* TargetMap, const FMapProperty* MapProperty, const void* KeyPtr, void* OutValuePtr)
{
	if(TargetMap)
	{
		FScriptMapHelper MapHelper(MapProperty, TargetMap);
		uint8* FoundValuePtr = MapHelper.FindValueFromHash(KeyPtr);
		if (OutValuePtr)
		{
			if (FoundValuePtr)
			{
				MapProperty->ValueProp->CopyCompleteValueFromScriptVM(OutValuePtr, FoundValuePtr);
			}
			else
			{
#if 1 //fix for it
				MapProperty->ValueProp->ClearValue(OutValuePtr);
#else
				MapProperty->ValueProp->InitializeValue(OutValuePtr);
#endif
			}
		}
		return FoundValuePtr != nullptr;
	}
	return false;
}

 

 

Steps to Reproduce
  1. Build and launch attached repro project
  2. Start standalone game with -LLM command line option
  3. Once launched the game, enter stat LLMFULL in console
  4. See EngineMisc tag in stat display

Result:

EngineMisc counter in stat display keeps increasing

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-272934 in the post.

1
Login to Vote

Unresolved
ComponentUE - Framework - Blueprint
Affects Versions5.5
CreatedApr 15, 2025
UpdatedApr 17, 2025
View Jira Issue