somdoron / AsyncIO

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible memory leak?

wmjordan opened this issue · comments

commented

I encountered a possible memory leak after running AsyncIO on an environment where connection resets or disconnections happen frequently.

I tried with some code to reproduce the problem and observed that the memory usage kept rising after full GC. The code could be downloaded here:
ConsoleApp1.zip

Run the code and it will keep creating servers and clients connecting each other and then closing the connections. The memory usage and generation object counts will be printed on the console.

....................................................................................................Finished
Mem used after GC:140432
Gen 0: 982
Gen 1: 13
Gen 2: 3
....................................................................................................Finished
Mem used after GC:146136
Gen 0: 1964
Gen 1: 25
Gen 2: 6
....................................................................................................Finished
Mem used after GC:152952
Gen 0: 2946
Gen 1: 37
Gen 2: 9
....................................................................................................Finished
Mem used after GC:160336
Gen 0: 3928
Gen 1: 49
Gen 2: 12
....................................................................................................Finished
Mem used after GC:164880
Gen 0: 4910
Gen 1: 61
Gen 2: 15
....................................................................................................Finished
Mem used after GC:167152
Gen 0: 5892
Gen 1: 72
Gen 2: 18

If you have Process Explorer (https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer), you can also double click the ConsoleApp1.exe process listed on it and take a look at the Gen 2 Heap Size from the .NET Performance tab in the process properties dialog. You will see that the Gen 2 Heap Size keep rising while the program runs.

default

After some times of running... the Gen 2 Heap Size and the Number of GC Handles had increased.
default

commented

After more than one month's running with tens of millions of connections and disconnections on the production machine, nothing could prove that there was a memory leak. I am closing this issue.