Skip to content

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

Open
Cybis320 wants to merge 9 commits into
prereleasefrom
gst-max-buffer
Open

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

Conversation

@Cybis320

@Cybis320 Cybis320 commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Targets the OOM / swap-spiral failures seen on memory-tight stations.

Capture memory (BufferedCapture, Compression, QueuedPool, ConfigReader)

  • New gst_queue_size config (default 100) drives the GStreamer queue/appsink max-buffers, previously hardcoded to 100. Lower it to shrink per-camera buffering on tight boxes. The buffer-fill % calc now uses it too.
  • Daytime release: the shared compression buffers (~0.5 GB/array) are returned to the OS while idle in daylight (MADV_REMOVE, with DONTNEED fallback) instead of lingering in swap until night.
  • MADV_DONTFORK on those buffers so GStreamer/RawFrameSaver grandchildren don't carry them.
  • Leak fixes: QueuedPool now owns its Manager and exposes shutdownManager() (called after getResults() in StartCapture/DetectStarsAndMeteors/ExtractStars); Compressor reaps unjoined procs and os._exit()s its run-exit paths so lingering Manager proxy threads don't block shutdown.

MultiCam updater (GRMSUpdater.sh)

  • New --reboot (always) / --reboot-if-needed (only when pending OS updates) flags; default unchanged. Stops stations cleanly before rebooting.
  • --reboot-if-needed uses /var/run/reboot-required, falling back to running-vs-installed kernel.
  • Requires passwordless sudo shutdown or the reboot is skipped with a warning. Stock Raspberry Pi OS already grants the default user blanket NOPASSWD sudo, so no setup is needed there. On hardened setups, grant just the shutdown command:
echo 'my_username ALL=(ALL) NOPASSWD: /usr/sbin/shutdown' | sudo tee /etc/sudoers.d/rms-reboot > /dev/null
sudo chmod 0440 /etc/sudoers.d/rms-reboot

For instance, this cron job checks for an RMS update daily, updates and restarts RMS if needed, and additionally reboots the machine if a reboot is required to complete an OS update:

0 19 * * * /home/<username>/source/RMS/Scripts/MultiCamLinux/GRMSUpdater.sh  --reboot-if-needed

@Cybis320 Cybis320 force-pushed the gst-max-buffer branch 2 times, most recently from c095b3d to efea83c Compare March 19, 2026 17:57
@Cybis320 Cybis320 marked this pull request as ready for review June 15, 2026 01:50
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