<p><strong>TLDR</strong>: If you are not getting OOM kills, you are fine. Leave it as is, kernel will reclaim memory when it is required/on demand.</p>
<p>What you ask is not &quot;possible&quot; 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).</p>
<p>In Kubernetes world, resource management and resource allocation is done by <a href="https://docs.kernel.org/admin-guide/cgroup-v1/cgroups.html" rel="nofollow noreferrer">cgroups</a>. 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.</p>
<p>I'd like to add that memory management is very complex topic, it is described in depth in the <a href="https://docs.kernel.org/admin-guide/mm/index.html" rel="nofollow noreferrer">https://docs.kernel.org/admin-guide/mm/index.html</a>.</p>

CC BY-SA 4.0
2023-06-25T13:09:46.277Z
2023-06-25T13:09:46.277Z
Kyslik
<p>I've got pods that use a greatly varying amount of memory over their lifetime.</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>

<kubernetes>
How can I take away RAM from a running Kubernetes pod?
Yotam Gilad
# How can I take away RAM from a running Kubernetes pod?

(Asked by: username_0 on 2023-06-24)

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.

**Tags:** kubernetes


---

## 1 answers

### Answer by username_1 on 2023-06-25. Score: 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](https://docs.kernel.org/admin-guide/cgroup-v1/cgroups.html). 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>.


---

