Post

Replies

Boosts

Views

Activity

Reply to Memory leak when no draw calls issued to encoder
[quote='871886022, pbantolas, /thread/812419?answerId=871886022#871886022, /profile/pbantolas'] That's my guess, worth adding a reset at the end to see if it fixes it. Still sounds like a bug so consider reporting it! [/quote] Good point. Tried reset()-ing but didn't do much. Also, printing the allocator's allocatedSize() shows constant ~2.5MiB There was no point really in doing this, it was mostly me playing with the Metal 4 API. If this is a legal program it should not leak is my position. It has to be the buffer. This version works and does not leak: func draw(in view: MTKView) { guard let drawable = view.currentDrawable else { return } commandQueue.waitForDrawable(drawable) commandQueue.signalDrawable(drawable) drawable.present() print(self.allocator.allocatedSize()) self.allocator.reset(); } but this version of draw does: func draw(in view: MTKView) { guard let drawable = view.currentDrawable else { return } commandBuffer.beginCommandBuffer(allocator: allocator) commandBuffer.endCommandBuffer() commandQueue.waitForDrawable(drawable) commandQueue.commit([commandBuffer]) commandQueue.signalDrawable(drawable) drawable.present() print(self.allocator.allocatedSize()) self.allocator.reset(); }``` Both of those aren't fully working though, as the view does not display its clear color. Something's not working right, I think. I'll file a bug.
Jan ’26
Reply to 26.4 RC documentation omits Foundation?!
https://developer.apple.com/forums/thread/820929
Replies
Boosts
Views
Activity
Apr ’26
Reply to Memory leak when no draw calls issued to encoder
It appears the memory consumption was due to the Shader and API Validation I had enabled in my scheme. Once I disabled these, memory use went back down to normal.
Replies
Boosts
Views
Activity
Jan ’26
Reply to Memory leak when no draw calls issued to encoder
[quote='871886022, pbantolas, /thread/812419?answerId=871886022#871886022, /profile/pbantolas'] That's my guess, worth adding a reset at the end to see if it fixes it. Still sounds like a bug so consider reporting it! [/quote] Good point. Tried reset()-ing but didn't do much. Also, printing the allocator's allocatedSize() shows constant ~2.5MiB There was no point really in doing this, it was mostly me playing with the Metal 4 API. If this is a legal program it should not leak is my position. It has to be the buffer. This version works and does not leak: func draw(in view: MTKView) { guard let drawable = view.currentDrawable else { return } commandQueue.waitForDrawable(drawable) commandQueue.signalDrawable(drawable) drawable.present() print(self.allocator.allocatedSize()) self.allocator.reset(); } but this version of draw does: func draw(in view: MTKView) { guard let drawable = view.currentDrawable else { return } commandBuffer.beginCommandBuffer(allocator: allocator) commandBuffer.endCommandBuffer() commandQueue.waitForDrawable(drawable) commandQueue.commit([commandBuffer]) commandQueue.signalDrawable(drawable) drawable.present() print(self.allocator.allocatedSize()) self.allocator.reset(); }``` Both of those aren't fully working though, as the view does not display its clear color. Something's not working right, I think. I'll file a bug.
Replies
Boosts
Views
Activity
Jan ’26
Reply to Unable to profile Metal app on M2 Ultra (profiling works on M3 Pro)
To clarify: this happens only for apps using the Metal 4 API. I can profile pre-Metal 4 apps on the Studio just fine.
Replies
Boosts
Views
Activity
Jan ’26
Reply to Metal 4: When is it ok to dealloc a MTLBuffer's memory
Thanks for your comment, and yeah, I figured as much by reading and playing around with various lifetimes.
Replies
Boosts
Views
Activity
Jan ’26