Connection Leak when using GetAsDatareader?

Posts   
 
    
erwin avatar
erwin
User
Posts: 21
Joined: 18-Feb-2005
# Posted on: 24-Sep-2017 17:49:09   

Hi, I have a connection leak in my web application which can be identified as this code - which looks quite innocent to me. What am I missing?

I can reproduce the problem when I set Max Pool Size to a small number.


 using (var reader = (SqlDataReader) dao.GetAsDataReader(null, fields, filter1, relations1,
                                CommandBehavior.Default, 0, true))
                            {
                                while (reader.Read())
                                {
                                    AnnotationCode ac1 = new AnnotationCode();
                                    ac1.Value = reader.GetInt64(0);
                                    ac1.Name = reader.GetString(1);
                                    a.AvailableOptions.Add(ac1);
                                }
                                reader.Close();
                            }

I Played around with reader.close() but no change. Shouldnt IDisposable / using() release the connection?

LLBLGEN 5.2.3, .net 4.7 (ASP.Net MVC5), SQL Server 2016

erwin avatar
erwin
User
Posts: 21
Joined: 18-Feb-2005
# Posted on: 24-Sep-2017 18:01:16   

Never mind, now I look at the code here in the forum,

CommandBehavior.CloseConnection ...

Regards erwin