#844·gopsutil

[mem] 'Cached' is not pulled straight from meminfo as documentation suggests

Author: C0rn3jCreated Feb 20, 2020Updated Sep 15, 2026

The documentation for VirtualMemoryStat makes it look like Cached is pulled from /proc/meminfo and would just be a raw value, but what is actually returned is Cached+SReclaimable.

The problematic line would be here, it seems this is done because further calculations that involve Cached also need SReclaimable, but SReclaimable is never substracted back in the final result, so Cached ends up returning incorrectly.

If this is by design, I think it should be mentioned in the documentation.

Workaround - simply substract the value yourself - cached = m.Cached-m.SReclaimable