/** * Settings › Memory Usage: memory of OpenIDEA, its language servers and other * processes, subsystem sizes, "Clear caches" and the status bar indicator toggle. */ import { useEffect, type ReactNode } from "react"; import clsx from "clsx"; import { Button, Checkbox } from "@/ui"; import { executeAction } from "@/platform/actions"; import { isTauri } from "@/platform/ipc"; import { isStatusItemVisible, setStatusWidgetVisible, useStatusWidgetOverrides } from "@/workbench/statusBarWidgets"; import { formatBytes, formatCount, formatMs, formatSize, formatUptime, memoryRatio } from "./format"; import { memorySections, summarizeMemory } from "./memory"; import { MEMORY_WIDGET } from "./MemoryStatus"; import { startPolling } from "./poll"; import { refreshMetrics, usePerf } from "./store"; import styles from "./MemoryUsage.module.css"; function Row({ label, value, strong, indented, }: { label: string; value: string; strong?: boolean; indented?: boolean; }) { return (
{label}: {value}
); } /** The same setting as the status bar context menu's "Memory Indicator". */ function IndicatorToggle() { const overrides = useStatusWidgetOverrides(); const shown = isStatusItemVisible(MEMORY_WIDGET, overrides); return ( void setStatusWidgetVisible(MEMORY_WIDGET.id, on)} label="Show memory indicator in the status bar" /> ); } function Section({ title, children }: { title: string; children: ReactNode }) { return (
{title}
{children}
); } export function MemoryUsagePage() { const m = usePerf((s) => s.metrics); const error = usePerf((s) => s.error); useEffect(() => { if (!isTauri()) return; return startPolling(() => void refreshMetrics(), { intervalMs: 2000 }); }, []); if (!isTauri()) return
Memory usage is available in the desktop app.
; if (!m) return
Loading…
; const summary = summarizeMemory(m); const own = (summary.app ?? 0) + (summary.languageServers ?? 0); const ratio = memoryRatio(own, m.totalMemoryBytes); return (
0 ? 1 : 0)}%` }} />
OpenIDEA and its language servers use {formatSize(own)} ({Math.round(ratio * 100)}%) of{" "} {formatSize(m.totalMemoryBytes)} physical memory.
{memorySections(m.memory ?? []).map((sec) => (
{sec.rows.map((r) => ( ))}
))} {m.heapBytes != null && }
Memory as the OS reports it (macOS: Activity Monitor’s “Memory”; Linux: PSS; Windows: private bytes), including child processes.
Drops syntax trees and EditorConfig data and compacts the index; they are rebuilt on demand.
“Process → main” is spent before any OpenIDEA code runs: exec, code-signature checks and dynamic loading. macOS scans a freshly built, unsigned debug binary for several seconds on its first launch.
{error &&
{error}
}
); }