简体   繁体   中英

Strange memory usage pattern in C# Windows Form app

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?

在此处输入图像描述

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM