Finalizer blocking on OracleClob.Dispose()
440057Jul 14 2006 — edited Jul 14 2006I am having an ASP.NET application that hangs and leaks memory under heavy load. Using windbg on the aspnet_wp.exe process, I can see that the following seems to be the problem:
0:008> kb
ChildEBP RetAddr Args to Child
0b23d7fc 7c90e9c0 7c91901b 00000590 00000000 ntdll!KiFastSystemCallRet
0b23d800 7c91901b 00000590 00000000 00000000 ntdll!ZwWaitForSingleObject+0xc
0b23d888 7c90104b 00fee7f0 608fa5af 0bfee7f0 ntdll!RtlpWaitForCriticalSection+0x132
0b23d890 608fa5af 0bfee7f0 0b23fbb4 61cefc5a ntdll!RtlEnterCriticalSection+0x46
WARNING: Stack unwind information not available. Following frames may be wrong.
0b23d89c 61cefc5a 0be7b240 0c001a04 00000000 oracore10!sltsmna+0xf
0b23fbb4 61c274fb 0c0019e4 0dd7af70 0dda3b4c oraclient10!kpultcfr+0xdae
0b23fbcc 0c8f0e82 0c0019e4 0dd7af70 0dda3b4c oraclient10!OCILobFreeTemporary+0x13
0b23fc54 799b5ed2 010a6b18 00000000 0c6c9468 OraOps10!OpsLobFreeTemporary+0x92
0b23fc64 799b6eb1 010a6abc 010a6abc 00000000 mscorlib_79990000+0x25ed2
0b23fca4 7920841d 0b23fd20 79210965 0b23fdfc mscorlib_79990000+0x26eb1
0b23fd30 792084e5 010a24b0 001511a0 0017c850 mscorsvr!MethodTable::CallFinalizer+0xee
0b23fd44 79207f69 010a24b0 0017e460 0b23fe70 mscorsvr!CallFinalizer+0x84
0b23fddc 7920857d 010a24b0 00000000 001511a0 mscorsvr!CallFinalizer+0x255
0b23fdf0 791b4de8 0b23fe70 791b3cf4 0b23fe58 mscorsvr!GCHeap::RestartEE+0x73
0b23fe38 79208550 0017e460 7920856a 0b23fe70 mscorsvr!Thread::DoADCallBack+0x5c
0b23fed8 79207d21 010aa358 00000000 00000000 mscorsvr!CallFinalizer+0x2fa
0b23ff20 7922d5e1 00000000 8565a020 8565a054 mscorsvr!GCHeap::FinalizerThreadStart+0xc2
0b23ffb4 7c80b50b 00163f10 00140001 00140640 mscorsvr!Thread::intermediateThreadProc+0x44
0b23ffec 00000000 7922d5a0 00163f10 00000000 kernel32!BaseThreadStart+0x37
The CLR stack looks like:
0:008> !clrstack
Thread 8
ESP EIP
0x0b23fc14 0x7c90eb94 [FRAME: InlinedCallFrame]
0x0b23fc04 0x0d117b44 [DEFAULT] [hasThis] Void Oracle.DataAccess.Types.OracleClob.Dispose(Boolean)
0x0b23fc84 0x0d117996 [DEFAULT] [hasThis] Void Oracle.DataAccess.Types.OracleClob.Finalize()
0x0b23fdfc 0x7920841d [FRAME: ContextTransitionFrame]
0x0b23fe58 0x7920841d [FRAME: GCFrame]
So it would appear that in the Finalizer it is waiting to enter some critical section.
I am trying to reproduce in a simple test case. However, I am wondering if there is a particular issue with Dispose() on LOB objects, and how exactly this should be handled in code. I am currently explicitly disposing of all my parameters before disposing the command and connection objects.