On FreeBSD the resident memory of a go binary grows pathologically till the OS rans out of swap and the binary is killed. In some cases, the binary is blocked in uwait state for forever. It takes days to make it happens, but in a machine only running the "go binary" it is possible to simulate this issue with 100% of accuracy.
A way to mitigate this issue is to use MADV_DONTNEED instead of MADV_FREE, after enable it, it is possible to see the resident memory grows and shrinks as much as the "go binary" needs it. Eventually, even when the OS is under memory pressure, I have observed the OS doesn't run out of swap and the "go binary" is not being killed.
The MADV_FREE although has many performance advantages, on FreeBSD it seems to have some downside, specially because it doesn't reduce the resident memory even under OS memory pressure. I think would be useful to provide a GODEBUG option for BSD in the same way it is provided for LINUX, it might help BSD users to mitigate these issues.
Tested with FreeBSD version: HEAD, 12.0-RELEASE-p4, 12-STABLE and 11-STABLE.
The text was updated successfully, but these errors were encountered: