Migrate to 5.6

Currently we are trying to migrate our iOS app to 5.6. But encountered critical issue. Application crashes soon after level is loaded.

To investigate issue we built engine from sources. And crash is happening in

FMetalSubBufferHeap::FMetalSubBufferHeap(FMetalDevice& MetalDevice, NS::UInteger Size, NS::UInteger Alignment, MTL::ResourceOptions Options, FCriticalSection& InPoolMutex)


        ParentBuffer = mtlDevice->newBuffer(FullSize, Options);

ParentBuffer is null. FullSize is 2MB, Options is zero.

In next test code MTLDevice reports that almost 1.5GB already allocated. And it is able to allocate FullSize/2 = 1MB.

		if (!ParentBuffer)
		{
			int32 currentAllocatedSize = mtlDevice->currentAllocatedSize();
			UE_LOG(LogMetal, Verbose, TEXT("ParentBuffer is NULL!"));
			ParentBuffer = mtlDevice->newBuffer(FullSize/2, Options);
			if (!ParentBuffer)
			{
				UE_LOG(LogMetal, Verbose, TEXT("ParentBuffer/2 is NULL!"));
				ParentBuffer = mtlDevice->newBuffer(FullSize/4, Options);
			}
		}

though we have no issues with UE5.4.

In UE5.7 changelog Epic claimed they refactored MetalRHI. So one of our assumptions is “maybe Epic introduced memory leak in metal rhi”.

We tried start app with arguments “-trace=default,memory -llm”. But unfortunately UnrealInsights does not connect to ios device (though it sais “Succesfully connected”) and trace file is not created on device when we start app with argument “-tracefile=memassert_trace2”. (Only log files, but no trace file)