Workspace heap retention versus OS release in Dyalog APL memory management
0 reputation · 17 Sept 2026, 22:59 UTC
0 reputation · 17 Sept 2026, 22:59 UTC
Goal: ascertain if Dyalog APL releases memory obtained from erased arrays back to the operating system while the session remains active, given that ⎕WA may show recovery while OS process size stays elevated.
Uncertainty: documentation notes that the interpreter may retain freed space in its internal heap for reuse, but does not specify when or if that heap is returned to the OS, and observed differences across versions and platforms leave the behavior unresolved.
Does Dyalog APL return freed heap memory to the operating system during a live session?
Under which version, platform, or MAXWS configuration does such return occur, if at all?
Is there a documented mechanism or configuration option to control or trigger mid-session heap release to the OS?
No — in normal operation Dyalog APL does not return freed workspace heap memory to the operating system during a live session. When you erase an array, the space goes back onto the interpreter's internal free list, which is why ⎕WA recovers. The OS-level process size (RSS on Linux/macOS, working set on Windows) generally stays at its high-water mark until the session ends. There is no documented user-facing command or configuration option that forces a mid-session release of committed heap pages.
Confirmed: ⎕WA measures available space inside the interpreter's workspace heap, not OS memory. Erasing arrays is an internal free-list operation, so ⎕WA recovering while Task Manager or VmRSS stays elevated is expected behavior, not a contradiction and not by itself evidence of a leak.
Likely explanation: like most long-lived interpreters, Dyalog retains freed blocks in its allocator for reuse. Once the heap has grown to accommodate a peak workload, the process footprint typically stays there for the life of the session. How much the underlying C runtime could return also differs by platform — glibc on Linux may hand back large mmap-backed allocations but rarely shrinks the main arena, and the Windows heap has its own thresholds — so observed behavior can vary between builds and OSes.
MAXWS only caps the maximum workspace size. It limits how large the heap can grow; it does not trigger release of memory already allocated. Setting a smaller MAXWS will lower the peak footprint but will not make a running session shrink.
⎕WA and OS process size each cycle (grep VmRSS /proc/<pid>/status on Linux, Task Manager on Windows). Retention shows RSS rising to a plateau and staying there; a real leak shows unbounded growth across identical cycles.If you need a definitive, version-specific statement of the heap-release policy, raise the scenario with Dyalog support — it is an implementation detail not fully specified in public documentation.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.