WinDbg learning Path, tortuous, many times the research progress is not much, today has made progress, records.
Microsoft Official Help document is very comprehensive: https://msdn.microsoft.com/zh-cn/library/windows/hardware/ff551063 (v=vs.85). aspx
The problem is found on the server, the server is WinServer2012 R2 x64. One of the Windows services, memory up to 7G. But this service, nothing to do, just timed to obtain data, update data. The entityframework used. With Task Manager, grab the package down and check it out. The dump bag is 7GB large.
1, prepare the environment, load sos.dll===========================
Start debugging, first WinDbg, divided into x64 and x86 versions. Because of the dump operating environment, 64-bit, so WinDbg should also be 64-bit, which will be the host debugging environment should also be 64 bits. My host environment is win8.1x64.
To run WinDbg, be sure to have administrator privileges.
Then, verify that SOS.dll is loaded. Use the. Chain command to view. If not loaded, the 64-bit SOS.dll is loaded. Because dump is x64 bit, so loading x32 bit is not, will prompt
"The callto LoadLibrary (C:\Windows\Microsoft.NET\Framework\v4.0.30319\sos.dll) failed, Win32 error 0n193
"%1 is not a valid Win32 application. ""
SOS.dll Microsoft Official Help document, https://msdn.microsoft.com/en-us/library/bb190764 (v=vs.110). aspx
2, commissioning ===================================
1),. CLS Clear screen.
2),!EEHEAP-GC View the managed heap, found that the 2 generation heap is very large, nearly 2.5G. So determine the problem here.
Each segment maximum 255m,begin is the start address, allocated is the ending address, the ending address minus the start address equals size, and the parentheses are 10 binary sizes. LOB is not big.
3), because dump is very big, the whole analysis is very slow, therefore only takes one second generation heap segment analysis. Dumpheap 000000008f591000 000000009f58ffe0
4), after a few minutes of analysis, the STAT Statistics section shows the largest type of string. The string type is analyzed again. Dumpheap-type String 000000008f591000 000000009f58ffe0
5), found string type, there are many 4KB strings, do not know what. Further analysis of large strings,! Dumpheap-type string-min 000000008f591000 000000009f58ffe0
6),!do View object, find string is error message. Before the contact, this system does always appear error behavior, but does not affect the use of the tube.
7),!gcroot-all View the reference, this operation is also relatively slow. A string is found to be an object property, and the object is a EF5 context table record.
8), repeat 6), 7) step, and discover that this is the case. Then this context has been valid, and the content has been quoted.
8), at this point, using IL to view the code, it is found that there is a static EF ObjectContext is referenced, this object lifetime is consistent with the process. ObjectContext will continue to grow due to long-term operation and data entry.
On this issue, I looked for the next EF-related document and did not seem to clean up the DbContext command.
In fact, this kind of operation is very common, for this reason, I have done the test procedure alone, has proved above conclusion.
Using system;using system.collections.generic;using system.linq;using system.text;namespace ConsoleApplication12{ Class Program {static It_monitorentities DB = new It_monitorentities (); static void Main (string[] args) {while (true) {Console.WriteLine ("Call Add y/ N "); Consolekeyinfo k = Console.readkey (); Console.WriteLine (""); if (K.key = = consolekey.y) {Console.WriteLine ("Add"); ADD (); }}}} static void Add () {for (int i = 0; i <; i++) { Db. Jobnotifies.add (New Jobnotify () {Remark = i.tostring () + "" + invarstr }); Db. SaveChanges (); }} static string invarstr = @ "You towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place to sprinkle you towering Aston hair place Aston Hair God HairWhere the oath is to sprinkle you with the lofty Aston Hair place Aston hair, God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place to sprinkle you towering Aston hair place Aston Oh, God, swear where the place is, you're the towering Aston hair place, aston hair. God swear place you towering Aston hair place Aston hair AH God swear place you towering emei hair place aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place to sprinkle you towering Aston hair place Where is the place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place to sprinkle you towering e aston hair You towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place to sprinkle you towering Aston hair place Aston hair, God swear place Swear where you're towering Aston hair place Aston hair AH God swear place you towering emei hair place aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place to sprinkle you towering Aston hair place Oh, Lord, swear to God, place your lofty Aston hair place, aston hair. God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you lofty aston hair place, God swear place you towering Aston hair place, God swear place to sprinkle you lofty The place where the lord of the hair, the god swear place to sprinkle you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair, God swear place Sprinkle you lofty aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place to sprinkle you towering Aston hair place Aston Hair AH God swear, place your towering Aston hair place, Aston, and God swear to the place you're toweringThe place where the lord of the hair, the god swear place to sprinkle you lofty e-Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair, God swear place to sprinkle your towering Aston hair place The square of your lofty Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you lofty Aston hair place of the place Aston hair Oh God swear places you towering Aston hair place Oh, God swear, place your towering Aston hair place, aston hair. God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place to sprinkle you towering Aston hair place Place Aston Hair God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place to sprinkle you towering Aston hair place. Aston Hair Place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering emei hair place aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place to sprinkle you towering Aston hair place Aston hair, God swear place, God hair Where the oath is to sprinkle you with the lofty Aston Hair place Aston hair, God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place you towering Aston hair place Aston hair AH God swear place to sprinkle you towering Aston hair place Aston hair AH God swear place }}
3. Help Information ================
1), WinDbg can use!help cmd. get help, such as!help dumpheap
2), available search memory s-u 0x017a1000 0x017c8c78 "ephemeral"
or search memory to the end. foreach (addr {s-[1]u 0x017a1000 0x017c8c78 "Ephemeral"}) {du ${addr}}
3),
WinDbg debugging high-memory. NET process Dump