Generation 1 Heap Consuming Gigs of Memory as Free Space

安稳与你 提交于 2021-01-27 12:40:55

问题


We've had a long term issue with one of our products consuming GBs of memory when in production. We often get low memory warnings on the server, and finally today I finally had chance to sit down with a memory profiler and see where the memory is going. In development, with the same database and config, the application's private working set is 450MB. On the production server, the amount of memory allocated to that process is 3.7GB.

Using Ants Memory Profiler, I determined that 2.906GB of that memory is being allocated to the Generation 1 Heap:

This amount of memory does get utilised on application start as we load a lot of data from the database to generate some caches. However, it all gets cleaned up, as you can see by the fact all of the data in the graph above is allocated, but not used. Here's the complete overview:

As you can see, the LOH is pretty much empty and not fragmented. I know that the LOH doesn't get compacted, unless you specifically set CompactOnce to the applicable GCSettings enum. But I was under the impression that the Generation 0-2 heaps do get compacted and should get free space released? Or does the CLR just assume that because that much memory was consumed once, that the application should keep addressing that memory in case it needs that much again?

To me, our app should only be consuming about 600-700MB (most of which is the CLR). So:

  1. Does anyone know why this free space is remaining allocated and only on a production server and not on development laptops?
  2. Is there any way to manually release this free memory from the gen 1 heap?

来源:https://stackoverflow.com/questions/34659229/generation-1-heap-consuming-gigs-of-memory-as-free-space

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!