I have done a simple experiment with both v1 and v2 cgroup memory controller on a 4.18 kernel that looks like this.
- I set the maximum memory limit accordingly. For v1 I write into the memory.limit_in_bytes and for v2 I write into the memory.max file.
I move the current bash instance into it (i.e. $$) and start a loop that does only ls. The limit is set to 8M bytes.
while [[ 1 ]]; do ls; done
After a while, the bash instance is terminated due to OOM. I do not understand why is this the case because the ls process will return the memory after it finishes so that it can be reused in the next iteration.
I am missing something?
Thanks,