none
Handle leak with Sql Connection and MARS RRS feed

  • Question

  • Hello I'm not able to report a bug via connect (because everything is japenese when I select .Net Framework ... and my japanese isn't the best) so I landed here.

    I'm experiencing a handle leak when

    • using SqlConnection
    • to connect to a Sql Server via TCP
    • with MARS (Multiple Active Resultsets) enabled
    • only with a x86 app (x64 doesn't show this behavior)
    • only on framework 4.5.2 (also on 4.5.3/4.6 - don't know the correct name)
    • large amount of data has to be selected

    Obviously when reducing the packet size (within connection string) the handle count increases; with larger packet size the handles also get wasted but not so much.

    When observing the app with process explorer it shows nameless handles of type 'Event'.

    Does anyone else experience this behavior?

    Sample code: Has to be executed multiple times (depending of data amount)
    using (SqlConnection conn = new SqlConnection(@"packet size=32768;server=tcp:[AnyServer];Connection Timeout=30;database=[AnyDatabase];Trusted_Connection=true;Pooling=true;MultipleActiveResultSets=true;"))
    {
    	conn.Open();
    	using (SqlCommand cmd = new SqlCommand("select * from [SomeTable]", conn))
    	{
    		using (SqlDataReader reader = cmd.ExecuteReader())
    		{
    			while (reader.Read())
    			{
    				// Do something
    			}	
    		}
    	}
    }




    Friday, May 29, 2015 12:24 PM

All replies

  • Hello Stefan,

    >>I'm experiencing a handle leak

    It is not sure if this is a connection leak since you already use the “Using” block, this should ensure all opened connection to be closed. Anyway, I suggest you could follow this blog: Connection leak , its symptoms and troubleshooting, to see if you could get help from it.

    >>When observing the app with process explorer it shows nameless handles of type 'Event'.

    Here I recommended you could try with the Windbg by using !htrace extension, this could help to debug what handles are leak, and by whom: Use !htrace to debug handle leak.

    >>Hello I'm not able to report a bug via connect (because everything is japenese when I select .Net Framework ... and my japanese isn't the best) so I landed here.

    Please try with this link: https://connect.microsoft.com/VisualStudio/Feedback/LoadSubmitFeedbackForm?FormID=6151 to see if you could post an English issue report.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, June 1, 2015 2:50 AM
    Moderator
  • Thanx for quick reply !!

    Seems like it's a call to System_Data!SOS_IOCompRequest::InitOvlEvent (see below). I found this call multiple times for each database access. Unfortunately there is information available on the web about InitOvlEvent.

    0x7784ff86: ntdll!NtCreateEvent+0x00000012
    0x75240d93: KERNELBASE!CreateEventExW+0x0000006e
    0x75241181: KERNELBASE!CreateEventExA+0x00000035
    0x75241762: KERNELBASE!CreateEventA+0x00000027
    0x6e4b06d2: System_Data!SOS_IOCompRequest::InitOvlEvent+0x00000013
    Monday, June 1, 2015 9:16 AM
  • Hello Stefan,

    >> Unfortunately there is information available on the web about InitOvlEvent.

    The function seems to be a kernel method, while I am not experienced about it, for this, I am trying to invoke someone experienced to help look into this case, this may take sometimes and as soon as we get any result, we will tell you.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, June 2, 2015 6:09 AM
    Moderator
  • Obviously I lost a 'no' in the last comment.

    Nevertheless ... thanx for the information!!

    Tuesday, June 2, 2015 11:16 AM
  • This never happened?
    Tuesday, June 4, 2019 9:46 PM