windbg - .net application memory leak when load html file in HtmlAgilityPack -
i have lot of html file need read , parse htmlagilitypack.when run application memory usage increase , release memory slow. when use windbg tool , check memory dump,found system.bytes[] used lot of memory.
the below pseudo-code:
open file
//read html file in disk var stream = openfile();// //de-compress in gzip mode var de_stream = gzip_decompress(stream); stream.close(); var doc=loadhtml(de_stream,encoding.utf8); //close close de_stream.close(); load html string
function loadhtml(stream,encoding)
var doc = new htmldocument(); using (var sr = new streamreader(stream, encoding, false,4096)) { var html = sr.readtoend(); doc.loadhtml(html); sr.close(); } when application running , open hundred of file(file average length 100k)
$dumpheap -stat 
$dumpheap -mt 56394944 -min 10240
check last object in mt 56394944 .
!do 3d67a240 
the other objects in mt 56394944 html content.when closed stream object in bytes array still hold in memory?
if change above code , remove loadhtml function call,everything okay,no high memory usage,no object in byte arrays hold in memory.
var stream = openfile(); var de_stream = gzip_decompress(stream); stream.close(); //var doc=loadhtml(de_stream,encoding.utf8);remove call de_stream.close(); i need suggestion,release byte array objects when loaded html file.
[edit] when use !gcroot [byte array address] no output.
.... object 0x188b0cb8 contains invalid object reference 0x1e7538f8. scan thread 25 osthread f40 scan thread 26 osthread 8e8 .... scan thread 30 osthread 16e0 object 0x237115f8 contains invalid object reference 0x24866df8. .... [edit]
i checkd gc static. 
Comments
Post a Comment