javascript - Getting image from webapi causes memory leak -
i have aurelia client gets image asp.net server via api. image served server holds emgu cv umat var. following method in controller image , displayed correctly.
this method results in memory leakage , can't seem orgin (not calling method, means no leak):
update, tried mawg's suggestion when close stream not show image. leak gone there no image.
[system.web.http.httpget] [system.web.http.route("dummymethod3")] public httpresponsemessage get2() { httpresponsemessage response = new httpresponsemessage(); try { console.writeline("get image 3"); ddengine.sem.waitone(); var memorystream = new memorystream(); resultimage.bitmap.save(memorystream, imageformat.png); memorystream.position = 0; var result = new httpresponsemessage(httpstatuscode.ok); result.content = new streamcontent(memorystream); result.content.headers.contenttype = new mediatypeheadervalue("image/png"); memorystream.close(); memorystream.dispose(); ddengine.sem.release(); return result; } catch { console.writeline("ex"); } return response; }
i have tried call collector @ several places in code like:
gc.collect(); gc.waitforpendingfinalizers();
when doing releases resources memory usege increasing. when not calling method there no increase!
my client code looks this:
updateimagesrc() { let dt = new date(); let baseurl = "http://localhost:8080/api/status/dummymethod3"; this.imagepath = baseurl + "?t=" + dt.gettime(); }
and html
<img id="img" src.bind="imagepath"/>
any suggestions welcome!
Comments
Post a Comment