<p>I'm checking on a scaling issue and we are suspecting it has something to do with the memory, but after running a load testing on local machine it doesn't seems to have memory leak.
We are hosting the .net core application in Kubernetes, with resources setting 800mi request memory without limit.
And as per describe from this <a href="https://www.c-sharpcorner.com/article/garbage-collection-in-dot-net/#:%7E:text=The%20trigger%20for%20Garbage%20collection,GC." rel="nofollow noreferrer">Article</a></p>
<blockquote>
<p>The trigger for Garbage collection occurs when, The system has low
physical memory and gets notification from OS.</p>
</blockquote>
<p>So does that mean GC is unlikely to kick in until my nodes are low on memory if we did not setup memory limit, and it will eventually occupied most of memory in node?</p>

<p>@Martin is right but I would like to provide some more insight on this topic.</p>
<p><a href="https://cloud.google.com/blog/products/gcp/kubernetes-best-practices-resource-requests-and-limits" rel="nofollow noreferrer">Kubernetes best practices: Resource requests and limits</a> is a very good guide explaining the idea behind these mechanisms with a detailed explanation and examples.</p>
<p>Also, <a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/" rel="nofollow noreferrer">Managing Resources for Containers</a> will provide you with the official docs regarding:</p>
<ul>
<li><p>Requests and limits</p>
</li>
<li><p>Resource types</p>
</li>
<li><p>Resource requests and limits of Pod and Container</p>
</li>
<li><p>Resource units in Kubernetes</p>
</li>
<li><p>How Pods with resource requests are scheduled</p>
</li>
<li><p>How Pods with resource limits are run, etc</p>
</li>
</ul>
<p>Bear in mind that it is very important is to have a good strategy when calculating how much resources you would need for each container.
Optimally, your pods should be using exactly the amount of resources you requested but that's almost impossible to achieve. If the usage is lower than your request, you are wasting resources. If it's higher, you are risking performance issues. Consider a 25% margin up and down the request value as a good starting point. Regarding limits, achieving a good setting would depend on trying and adjusting. There is no optimal value that would fit everyone as it depends on many factors related to the application itself, the demand model, the tolerance to errors etc.</p>
<p>And finally, you can use the <a href="https://github.com/kubernetes-sigs/metrics-server#kubernetes-metrics-server" rel="nofollow noreferrer">metrics-server</a> to get the CPU and memory usage of the pods.</p>
