performance - C# Selenium Screenshot.SaveAsFile - Does Not Release Memory -
i have following code taking screenshot of web page , saving file
screenshot screenshot = ((itakesscreenshot)webdriver).getscreenshot(); screenshot.saveasfile($"{filefullname}.png", imageformat.png);
when debugging, in vs performace window can see memory jump of around 70-100mb (depending on page size) when calling saveasfile() not release when method finishes executing.
is there way force screenshot object dispose?
you can force garbage collection happen calling gc.collect
. however, shouldn't reasons explained here.
.net automatically handles freeing memory unused objects aren't being referenced anymore. garbage collection forces threads stop while occurring calling have toll on application.
Comments
Post a Comment