dashboard: show SoulSync's own RAM next to system memory %

the Memory Usage stat showed only global system memory (psutil.virtual_memory().percent).
add the process's own resident set size (RSS) — the real 'how much RAM SoulSync uses' number —
formatted MB under 1GB, GB above. headline stays the system %, subtitle now reads 'SoulSync ·
612 MB' instead of the generic 'Current usage'. graceful fallback if psutil errors / older
backend. useful context after the recent RAM-footprint discussions.
This commit is contained in:
BoulderBadgeDad 2026-06-27 13:42:14 -07:00
parent 6802399805
commit 5a54ffe14a
3 changed files with 16 additions and 4 deletions

View file

@ -2837,9 +2837,15 @@ def _build_system_stats():
uptime_seconds = time.time() - start_time
uptime = str(timedelta(seconds=int(uptime_seconds)))
# Get memory usage
# Get memory usage — global system %, plus SoulSync's own resident memory (RSS),
# so the dashboard can show "system load" and "how much RAM SoulSync itself uses".
memory = psutil.virtual_memory()
memory_usage = f"{memory.percent}%"
try:
_proc_rss_mb = psutil.Process(os.getpid()).memory_info().rss / (1024 * 1024)
process_memory = f"{_proc_rss_mb:.0f} MB" if _proc_rss_mb < 1024 else f"{_proc_rss_mb / 1024:.1f} GB"
except Exception:
process_memory = None
# Count active downloads from download_batches (batches that are currently downloading)
active_downloads = len([batch_id for batch_id, batch_data in download_batches.items()
@ -2917,7 +2923,8 @@ def _build_system_stats():
'download_speed': download_speed_str,
'active_syncs': active_syncs,
'uptime': uptime,
'memory_usage': memory_usage
'memory_usage': memory_usage,
'process_memory': process_memory
}
@app.route('/api/system/stats')

View file

@ -893,7 +893,9 @@ async function fetchAndUpdateSystemStats() {
updateStatCard('download-speed-card', data.download_speed, 'Combined speed');
updateStatCard('active-syncs-card', data.active_syncs, 'Playlists syncing');
updateStatCard('uptime-card', data.uptime, 'Application runtime');
updateStatCard('memory-card', data.memory_usage, 'Current usage');
// system memory % headline + SoulSync's own RSS in the subtitle (#935 follow-up)
updateStatCard('memory-card', data.memory_usage,
data.process_memory ? `SoulSync · ${data.process_memory}` : 'Current usage');
} catch (error) {
console.warn('Could not fetch system stats:', error);

View file

@ -687,7 +687,10 @@ function handleDashboardStats(data) {
updateStatCard('download-speed-card', data.download_speed, 'Combined speed');
updateStatCard('active-syncs-card', data.active_syncs, 'Playlists syncing');
updateStatCard('uptime-card', data.uptime, 'Application runtime');
updateStatCard('memory-card', data.memory_usage, 'Current usage');
// Headline is system memory %; subtitle shows SoulSync's own RSS so users can see the
// app's actual footprint (falls back to the generic label on older backends).
updateStatCard('memory-card', data.memory_usage,
data.process_memory ? `SoulSync · ${data.process_memory}` : 'Current usage');
}
function handleDashboardActivity(data) {