Strange memory usage pattern in C# Windows Form ap

2019-09-03 09:21发布

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?

enter image description here

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.

enter image description here

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

enter image description here

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?

enter image description here

1条回答
神经病院院长
2楼-- · 2019-09-03 10:23

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.

查看更多
登录 后发表回答