Thanks @parrykhai for identifying the unmatched drawable retain. We independently reproduced the same issue in a UE 5.8.4 packaged Mac Development build (SF_METAL_SM5), and the suggested removal fixed the per-frame CAMetalDrawable accumulation in our tested executable.
Environment: Mac Studio, Apple M1 Max, 64 GB unified memory, macOS 26.4.1. Normal onscreen rendering at 1809 x 1018, not NullRHI or render-offscreen.
We also traced a separate accumulation of autoreleased temporary objects through Metal submission/translation worker paths. In our allocation-stack captures, live CFData allocations came predominantly from driver UTF8String/command-encoding work reached through FMetalCommandQueue::CommitCommandBuffer and FMetalCommandEncoder::SignalEvent. These functions lacked local autorelease-pool scopes. We added MTL_SCOPED_AUTORELEASE_POOL at the start of both functions.
The minimal renderer patch against our installed 5.8.4 source is:
--- a/Engine/Source/Runtime/Apple/MetalRHI/Private/MetalViewport.cpp
+++ b/Engine/Source/Runtime/Apple/MetalRHI/Private/MetalViewport.cpp
@@ -1029,6 +1029,4 @@
}
#else
- CA::MetalDrawable* LocalDrawable = GetDrawable(EMetalViewportAccessDisplayLink);
- LocalDrawable->retain();
CommittedDrawables.Add(GetCommittedDrawableToPresent(std::numeric_limits<int32>::min(), CommandBuffer, bLayersToDraw));
--- a/Engine/Source/Runtime/Apple/MetalRHI/Private/MetalCommandQueue.cpp
+++ b/Engine/Source/Runtime/Apple/MetalRHI/Private/MetalCommandQueue.cpp
@@ -132,4 +132,5 @@
void FMetalCommandQueue::CommitCommandBuffer(FMetalCommandBuffer* CommandBuffer)
{
+ MTL_SCOPED_AUTORELEASE_POOL;
check(CommandBuffer);
INC_DWORD_STAT(STAT_MetalCommandBufferCommittedPerFrame);
--- a/Engine/Source/Runtime/Apple/MetalRHI/Private/MetalCommandEncoder.cpp
+++ b/Engine/Source/Runtime/Apple/MetalRHI/Private/MetalCommandEncoder.cpp
@@ -885,4 +885,5 @@
void FMetalCommandEncoder::SignalEvent(MTLEventPtr Event, uint32_t SignalCount)
{
+ MTL_SCOPED_AUTORELEASE_POOL;
check(CommandBuffer);
We rebuilt MetalRHI from source, rebuilt the full game package, and checked that the actual packaged executable contained the repairs. Merely editing the source alongside a precompiled renderer would not validate the change.
The following sustained measurements test all three changes together:
- Before repair: one full hour of a gameplay route, then 15 minutes at acknowledged character selection.
- After repair: a fresh full hour of the same gameplay route, then 15 minutes at acknowledged character selection. Separate sessions had different scene populations and cache warm-up.
- Aggregate heap snapshots used
heap -s -H --noContent PID only during character selection. No forced GC or allocation-stack logging was enabled during the sustained repaired run.
| Live class |
Before repair: early → late idle |
After repair: early → late idle |
| CAMetalDrawable |
218,073 → 254,721 |
2 → 2 |
| CFData |
3,586,884 → 4,358,747 |
234 → 234 |
| CFString |
3,605,512 → 4,377,360 |
18,777 → 18,777 |
Before-repair snapshots began at approximately 32 and 656 seconds after logout; repaired snapshots began at approximately 98 and 781 seconds. Snapshot attachment can briefly perturb residency, so the chart includes those variations rather than smoothing them away.
After the cleanup window, repaired game-process physical footprint had a median of 4.084 GiB (range 4.052-4.151 GiB), ending at 4.080 GiB. The data/string/drawable class counts above were identical across the two repaired snapshots. The chart measures game-process physical footprint only, with shutdown samples excluded; overlapping resource counters and the separate managed child process are not added to it.
Seven focused regression cases exercised the actual renderer methods for drawable ownership (including delayed command-buffer completion) and Cocoa temporary-object lifetimes. Those cases failed against the original methods and passed against the repaired methods. The packaged native acceptance checks and the complete rendered gameplay/idle run also passed.
Validation scope is this packaged SM5 build and the measured 60-minute gameplay plus 15-minute idle run. Longer-duration behavior and SM6 have not been validated. The sustained results are for the combined patch; they do not separately quantify the contribution of each autorelease-pool insertion. We are sharing the drawable confirmation here, with the related worker-pool findings and minimal patch for investigation/upstream review.