![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
Hi ASuurkuusk, Thanks for your post. I have tried to use "Microsoft .NET Framework SDK v2.0" command prompt to lauch the windbg and load SOS.dll. However, in windbg, !DumpModule or !DumpMT does not cause any significant increase in "Task Manager" "VM size" value. Have you tried other VS2005 machine's SOS.dll? If this problem is reproducable on other machine, I suggest you provide the detailed steps to help us reproduce the problem. Thanks Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. |
#4
| |||
| |||
|
|
Hi ASuurkuusk, Thanks for your post. I have tried to use "Microsoft .NET Framework SDK v2.0" command prompt to lauch the windbg and load SOS.dll. However, in windbg, !DumpModule or !DumpMT does not cause any significant increase in "Task Manager" "VM size" value. Have you tried other VS2005 machine's SOS.dll? If this problem is reproducable on other machine, I suggest you provide the detailed steps to help us reproduce the problem. Thanks Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. |
#5
| |||
| |||
|
#6
| |||
| |||
|
#7
| |||
| |||
|
|
Hi Andreas , Sorry for letting you wait. Based on the discuss with the product team, they confirmed that the 2.0 SOS just makes calls into the framework to get the data and the framework gets loaded in windbg process. Also, some of the commands cache data so that subsequent lookups don't take as long. So this is not identified as a leak. Hope this helps! Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. |
#8
| |||
| |||
|
|
Hi, I did perform some debugging into sos.dll before reporting this issue, and I am aware that the runtime dll and mscordacwks.dll get loaded into the windbg process and that some data gets cached. However, this is not the problem. The problem is that the cache does not get reused between sos commands. If you looked at the movie I provided (http://www.scitech.se/temp/sosleak2.avi), you would have seen that I issued a DumpMT command for the same method table (7b473dfc) several times. Each time the memory usage of windbg.exe increased with about 6 MB. If the data about the provided method table was cached, then the memory usage should certainly not increase. In order to provide you with some more information about this problem, I performed some additional debugging of sos.dll and dbgeng.dll. I managed to pinpoint the problem to the LoadClrDebugDll function in sos.dll. The LoadClrDebugDll gets called each time an sos command is performed. It makes a call to dbeng.dll!ExtIoctl (using ExtensionsApis.lpIoctlRoutine) with IoctlType set to 0x26, which will create a new "CLRData" instance using CLRDataCreateInstance. This new instance is then assigned to g_clrData, overwriting the previous instance of "CLRData", which I believe causes the memory leak. I performed a test where I modified the LoadClrDebugDll function so that it only runs once (on subsequent calls it returns immediately). This avoids creating and leaking "CLRData" instances and it seems like sos.dll works correctly, without leaking any memory. At the end of this post I have provided my (partially and manually) decompiled code for LoadClrDebugDll and ExtIoctl. I have marked the sections where I believe there is a problem with "PROBLEM:". I don't know if it will cause any side effects, but adding "if( g_clrData != NULL ) return;" to LoadClrDebugDll, will probably avoid the memory leak. Another thing that I have noticed, is that this memory leak doesn't occur when sos.dll is loaded into VS 2005. I have not investigated this further, but since VS doesn't use dbgeng.dll, I assume that ExtIoctl (0x26) in the VS implementation will return the same "CLRData" instance each time it's requested. Best regards, Andreas Suurkuusk SciTech Software AB struct CLRDebugData { IID* iid; void** iface; } IID IID_IClrData = 5c552ab6_fc09_4cb3_8e36_22fa03c798b7 SOS.dll!LoadClrDebugDll() { CLRDebugData data; data.clsId = &IID_IClrData; if( ExtensionsApis.lpIoctlRoutine( 0x26, &data, sizeof( CLRDebugData ) ) != 0 ) { // PROBLEM: Will overwrite previous g_ClrTarget (memory leak ~ 5MB!) g_clrData = data.iface; } } ULONG dbgeng.dll!ExtIoctl(USHORT IoctlType, PVOID lpvData, ULONG cbSize) { switch( IoctlType ) { case 0x26: if( g_Process != NULL && cbSize == sizeof( CLRDebugData ) ) { CLRDebugData* data = (ClrDebugData*)lpvData; g_Process->LoadClrDebugDllForExt(); if( g_Process->pCLRDataCreateInstance != NULL ) { // PROBLEM: Will create a new IClrDataTargetInstance each time if( g_Process->pCLRDataCreateInstance( *data->iid, g_Process->target, data->iface ) == S_OK ) return (ULONG)TRUE; } } break; case ...: break; } ... } ""Jeffrey Tan[MSFT]"" wrote: Hi Andreas , Sorry for letting you wait. Based on the discuss with the product team, they confirmed that the 2.0 SOS just makes calls into the framework to get the data and the framework gets loaded in windbg process. Also, some of the commands cache data so that subsequent lookups don't take as long. So this is not identified as a leak. Hope this helps! Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. |
#9
| |||
| |||
|
#10
| |||
| |||
|
|
Hi Andreas, Very cool! I have forward your debugging information to the sos.dll owner, I will feedback any progress here. Personally, I am curious about some of your debugging details. 1. Do you get the source code of the functions in dbgeng.dll by disasssembling with symbols in windbg? 2. If you can do reverse engineering to the function, how do you "adding "if( g_clrData != NULL ) return;" to LoadClrDebugDll"? Do you modify the executing process in windbg in debugging-time? Thanks Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |