dotnet-db-samples
dotnet-db-samples copied to clipboard
Memory leak on Oracle 11.2 with LONG datatype in .net core 3.1 on Linux
Hi,
I got the following config:
- Oracle Database 11g Release 11.2.0.4.0 - 64bit Production on Linux
- Net core 3.1 and Oracle.ManagedDataAccess.Core 3.21.1 - Linux
- Table with LONG column
when i query simple select through standart OracleDataReader - my net core app memory constantly increases.
Even if query returns no rows memory leak is still happens.
Are you closing/disposing all ODP.NET objects you use, including parameter objects? It's not uncommon to see memory leaks when not all objects are closed/disposed explicitly. Under stress conditions, the GC will not perform collections as often to return memory to the managed heap thereby causing the app's memory use to keep accumulating.
If you are closing/disposing all your ODP.NET objects, can you publish a reproducible test case for us to diagnose and resolve?
my code is pretty common
using var connection = new OracleConnection(_connectionString);
connection.Open();
var query = @"SELECT ID, BODY FROM MYTABLE where 1=0";
using var cmd = new OracleCommand(query, connection);
using var rdr = cmd.ExecuteReader();
if(!rdr.HasRows)
{
rdr.Close();
connection.Close();
return;
}
BODY column has LONG datatype, ID column is NUMBER
Bug can be observed on 11.2g.
I run net core app on Linux - and there is memory leak. It seems there is no bug on Windows
Maybe it somehow connected to this bug https://support.oracle.com/knowledge/Oracle%20Database%20Products/1050515_1.html
@skaeff I tried running your test case in an infinite loop with ODP.NET Core on Windows against an 11.2.0.4 DB, but did not see any memory accumulation.
I can try on Linux. Which Linux distro and version are you using? I'm less familiar with Linux monitoring tools. What memory monitoring tool are you using?
Hi,
I'm running Oracle Linux Server 7.8 (Kernel Version: 4.14.35-1902.304.6.el7uek.x86_64) and Net Core 3.1
You can use the following memory-check commands in Linux: free, top
My full config is below (actually, i run all code in k8s kluster and my app also runs in docker container):
https://github.com/skaeff/tests/blob/main/Dockerfile
https://github.com/skaeff/tests/blob/main/version.txt
PS: I dont think that k8s cluster matters in this case, try to run and catch memory leak on bare Linux.
.NET 3.1 is out of support and 11.2 is generally out of support as well.