Architecture & Performance
OSMV v5.1.0 is written in native C++20 using a dual-process architecture engineered for minimal RAM and near-zero idle CPU usage while streaming.
The Dual-Process Model
Keeping a graphical context and GPU driver buffers open in the background consumes unnecessary memory during a stream. OSMV isolates background polling from the UI:
- The Background Daemon:
- Windows (
OSMV.exe): Single portable executable (~1.94 MB, no external DLLs). DirectX 11, DXGI, and DWM DLLs are marked/DELAYLOADso the daemon never maps GPU libraries into memory, consuming only ~4.5 to 6 MB of private RAM. - Linux (
osmv): Built as a standalone daemon binary that links onlylibdbus-1,libcurl, andpthreads—zero X11, Wayland, OpenGL, or GTK dependencies. - Handles media polling (WinRT SMTC / D-Bus MPRIS), Discord IPC, Time/Date/Timers, native System Info sampling, Textline Changer, and a dedicated network worker thread for Dynamic Files and Twitch Helix so HTTP calls never stall local 1-second timers.
- Windows (
- The Configuration GUI (
--gui/osmv-gui):- Uses Dear ImGui (Win32 + DirectX 11 on Windows; GLFW + OpenGL 3 on Linux) with event-driven frame pacing (
0.25swhen idle,0.016sduring animations or user input). - Uses ~51 to 58 MB of private RAM on Windows while open.
- Closing the window
[X]or clicking Mode Headless / Minimize to Tray terminates the GUI process and releases 100% of its graphics memory back to the OS immediately.
- Uses Dear ImGui (Win32 + DirectX 11 on Windows; GLFW + OpenGL 3 on Linux) with event-driven frame pacing (
Execution Flow
- Startup: Running
OSMV.exe(or./osmv) acquires a single-instance lock (Local\osmv-daemon-instance-v3on Windows,flockin$XDG_RUNTIME_DIRon Linux).- If no daemon is running: starts the background daemon, initializes the system tray icon (
Shell_NotifyIconWon Windows; D-BusStatusNotifierItem+com.canonical.dbusmenuon Linux), and launches the GUI unless--silentis passed or Open GUI on launch is disabled. - If a daemon is already running: sends a
show_guiIPC message to wake/open the GUI and exits.
- If no daemon is running: starts the background daemon, initializes the system tray icon (
- Headless Mode: Closing the GUI window keeps the daemon running unobtrusively in the system tray.
- Quit: Clicking Quit OSMV in the GUI or tray menu signals the daemon to shut down cleanly and clears
shared/current_song.jsonandshared/current_song.js(null).
Local IPC & Disk Optimization
The daemon and GUI communicate over a length-prefixed JSON local IPC channel:
- Windows: Named Pipe
\\.\pipe\osmv-ipc-v3 - Linux: Unix Domain Socket
$XDG_RUNTIME_DIR/osmv-ipc-v3.sock(fallback/tmp/osmv-ipc-v3-<uid>.sock)
Key performance optimizations:
- Instant IPC Control: The GUI polls
get_stateevery500 msonly while open and sendsreload_settings,chrono_down,chrono_up,textline_next,twitch_search_games,twitch_update_channel, andquitcommands without duplicating WinRT/MPRIS polling in the GUI process. - Change-Cached Atomic Writes: Text files are tracked in memory (
CachedTextWriter) and written atomically via.tmp+ rename only when their formatted output actually changes. - Track-Change Artwork Caching: Album artwork streams from WinRT/MPRIS are read and Base64-encoded only when the track changes, eliminating per-second image allocations.
Last updated on