opening xps request .net causes memory leak
the following formula dash illustrates memory trickle opening xps files. run watch assign manager, grow redeem memory until app exits.
'****** console concentration begins.
module main
const defaulttestfilepath twine = "d:\test.xps"
const defaultloopruns integer = 1000
open servant main(byval args string())
low pathtotestxps twine = defaulttestfilepath
low numberofloops integer = defaultloopruns
(args.count >= 1) following pathtotestxps = args(0)
(args.count >= 2) following numberofloops = cint(args(1))
console.clear()
console.writeline("start - {0}", gc.gettotalmemory(true))
loopcount integer = 1 numberofloops
console.cursorleft = 0
console.write("loop {0:d5}", loopcount)
' some-more challenging xps request some-more loops, some-more memory lost.
controlling xpsitem new windows.xps.packaging.xpsdocument(pathtotestxps, system.io.fileaccess.read)
low fixeddocsequence windows.documents.fixeddocumentsequence
' line leaks brick memory any time, commented out does not.
fixeddocsequence = xpsitem.getfixeddocumentsequence
finish using
next
console.writeline()
gc.collect() ' line effect, i cruise memory leaked unmanaged (c++ xps internals).
console.writeline("complete - {0}", gc.gettotalmemory(true))
console.writeline("loop finish nonetheless memory released, redeem app exits (press pivotal exit).")
console.readkey()
finish sub
end module
'****** console concentration ends.
the reason loops thousand times since formula processes lots files leaks memory fast forcing an outofmemoryexception. forcing rubbish collection does work (i think an unmanaged brick memory xps internals).
the formula creatively another thread category nonetheless simplified this.
any assistance severely appreciated.
ryan
Comments
Post a Comment