"A container can use more memory resources than its limit", Why this occurs? Even after setting a limit how it can able to access more memory

Please explain this. “A container can use more memory resources than its limit”, Why this occurs? Even after setting a limit how it can able to access more memory.

This is to allow a very common practice in programming, where you allocate memory for a task, immediately do the task, and deallocate the memory. This is done in back-ground in many programming languages as well, so it can happen even if you’re not directly aware of it if you are programming in python or PHP, or even Java or Go.

So the memory checks in K8s are designed to deal with this practice. If memory use goes over the max very briefly, the system will allow for it. If memory is leaking (very bad) or if the program just grabs lots of memory and keeps hanging on to it, the system will create an Out Of Memory (OOM) error, and OOMKill the container.