|
|
|
|
|
by jacobgold
59 days ago
|
|
No, do not try to use mlock to avoid swapping, except in very specific scenarios. That way lies madness. To be more explicit about my advice: disable swap and ensure you have sufficient memory for your workload. Your 14 MB Go binary is not the source of your memory pressure. Your memory pressure is coming from the allocated anonymous pages supporting your programs data structures on the heap. Have sufficient memory for your workload, monitor it, and let the Go GC and kernel manage memory normally. This will work exactly as you'd hope. |
|
You are correct, that 90MB Go binary is not major memory consumer. But it doesn't matter what is the source of memory pressure. What matters is what kernel do under pressure. If you disable swap, then under memory pressure kernel can only pageout memory mapped files, no matter how small they are. And your code will be paged out.