0

I've got pods that use a greatly varying amount of memory over their lifetime.

If I understand correctly, in K8S, if a pod gets more memory (growing from request to limit), it doesn't relinquish it back to the common pool, even after it no longer needs it.

So I ended up in a situation where I've got many pods, all of which have lots of RAM that they don't need for 95% of their lifetime.

So, is there any way to get memory back from greedy pods when they're inactive? Without killing them I mean, as that would present its own complications.

1 Answer 1

1

TLDR: If you are not getting OOM kills, you are fine. Leave it as is, kernel will reclaim memory when it is required/on demand.

What you ask is not "possible" from user point of view (beyond killing the process). The memory is claimed/used and can be freed only by process itself or kernel (memory reclaiming / OOM-killer etcetera).

In Kubernetes world, resource management and resource allocation is done by cgroups. Essentially what happens is resources are sliced up. Many times the sum of all limits on a particular node/worker go over its physical capacity, this is called overcommitting. Overcommitting is double-edged sword, on one hand you can fit more workloads on a node/worker but once there is higher traffic/load (and application requires more resources) it can be OOMkilled or throttled to stand still.

I'd like to add that memory management is very complex topic, it is described in depth in the https://docs.kernel.org/admin-guide/mm/index.html.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.