Far-Beyond-Pulsar/Pulsar-Native
View on GitHubPlugin system memory leak (`Arc<>` over FFI)
Open
#261 opened on Jun 16, 2026
Cleanupbugenhancementhelp wanted
Repository metrics
- Stars
- (348 stars)
- PR merge metrics
- (PR metrics pending)
Description
Intro
Arc<> is not at all FFI safe. Currently We have an issue in the plugin system where GPUI (WGPUI) unavoidably depends on Arc internally which cannot change.
The leak
- On frame a plugin is told "render me a frame of your UI" where it returns a heavily nested data structure including Arc data internally.
- This data is leaked across frames because when passed over FFI boundaries, the atomic counter disconnects creating a plugin-side and engine-side counter that never sync.
This means when the engine is done with the arc its atomic counter decrements, and so the memory deallocates. HOWEVER the plugin side counter is never updated and the memory is leaked on each render call.