Skip to content

Fix memory leaks: zombie Compressor processes and inherited shared buffers#855

Draft
Cybis320 wants to merge 5 commits intoprereleasefrom
gst-max-buffer
Draft

Fix memory leaks: zombie Compressor processes and inherited shared buffers#855
Cybis320 wants to merge 5 commits intoprereleasefrom
gst-max-buffer

Conversation

@Cybis320
Copy link
Contributor

@Cybis320 Cybis320 commented Mar 19, 2026

  • Make GStreamer queue size configurable (gst_queue_size) to allow tuning on memory-constrained multi-camera systems
  • Fix Compressor processes surviving stop() at dawn: the forked QueuedPool Manager proxy threads hold open socket connections that prevent process exit. Whether the process exits cleanly depends on timing during cleanup, under memory pressure, cleanup is more likely to hang, creating a zombie that persists until the next restart. Each failed cleanup leaks ~450 MB (720p) to ~1.2 GB (1080p) per camera, and the problem compounds: more zombies mean more memory pressure, which means more zombies. Fixed by calling os._exit(0) after run() completes.
  • Fix QueuedPool Manager server process leaking: the multiprocessing.Manager() was created as a local variable and its server process was never shut down, persisting as an orphan. Now saved as an instance attribute and explicitly shut down after detection results are collected.
  • Fix RawFrameSaver inheriting compression frame buffers: when BufferedCapture forks the RawFrameSaver subprocess, it inherits the two large compression frame buffers (~225 MB each at 720p, ~506 MB each at 1080p) that it never uses. Added cleanup that removes these buffers from child processes after fork, saving ~450 MB to ~1 GB per camera.

@Cybis320 Cybis320 force-pushed the gst-max-buffer branch 2 times, most recently from c095b3d to efea83c Compare March 19, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant