mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
On macOS, Objective-C methods frequently return autoreleased objects that accumulate until an autorelease pool is drained. Our event loop (Core::EventLoop) and rendering thread both lacked autorelease pools, causing unbounded accumulation of autoreleased objects. The rendering thread was the worst offender: every Skia flush triggers Metal resource allocation which sets labels on GPU textures via -[IOGPUMetalResource setLabel:], creating autoreleased CFData objects. With ~1M+ such objects at 112 bytes each, this leaked ~121MB. Metal command buffer objects (_MTLCommandBufferEncoderInfo, etc.) also accumulated, adding another ~128MB. Add Core::ScopedAutoreleasePool, a RAII wrapper around the ObjC runtime autorelease pool (no-op on non-macOS), and drain it: - Every event loop pump (like NSRunLoop does) - Every compositor loop iteration on the rendering thread
23 KiB
23 KiB