Strange memory usage pattern in C# Windows Form app

折月煮酒 提交于 2019-12-25 14:39:30

问题


I am trying to understand what is going on in app written in C#. Below are several images taken from Performance Monitor. The blue line is #Bytes in all Heaps. The green line is Large Object Heap Size. I start the app and log me in. The app remains idle. The first image shows that LOH increases for some reason and then drops. A pattern is very clear. What is responsible for such behavior?

More. I do some heavy processing starting in A (see image below) using an Oracle Database through ODP.NET. After that the app remains idle again. The LOH does not drop. Instead it keeps increasing for some reason. Note that the application is idle. It is just open in my desktop. I am not even interacting with it.

Memory keeps increasing (each image represents 1:15:00).

After more than 2 hours suddenly it decreases and after while it starts increasing/decreasing again (see below) as in the first image. All the time app is idle. What is going on? Is it a memory leak? I don't think so. We profiled the app and couldn't find anything. Also the LOH increases without any activity. There is no open connection with the Oracle Database. Can ODP.NET be the culprit?


回答1:


The problem definitely is due ODP.NET. If I disable the connection pool the problem does not manifest. For each connection ODP.NET seems to create 2 threads and at 3 minutes interval (as seen in the images) ODP.NET does some housekeeping but for some reason allocates memory that are not released right away.

It is easy to reproduce. Just create a simple app that when a button is pressed a connection to an Oracle database is open and a stored procedure is executed. You will notice the pattern of the first image. The pattern of the other images is due the number of connections created by the app.



来源:https://stackoverflow.com/questions/6791764/strange-memory-usage-pattern-in-c-sharp-windows-form-app

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