I’m writing an application that spawns and kills a Chrome Browser. While I’m killing the process programatically (same effect as killing process through Windows Task Manager), it’s been suggested that this may also result in memory leak–ie from elements such as kernel resources that were not properly associated w/ the originating process.
Is it possible to for an application to leak memory or otherwise have irreclaimable memory after the Process has been killed?
Killing a process in task manager directly could result in memory leak.
An evidence is keeping killing “explorer.exe” will slow down the entire OS.
Each Chrome window has a GUI process and a background process for each active tab. Background processes is reponsible for fetching page content, sending request / posting data, and hold fewer kernel object handles than GUI processes.
Any programming framework will have at least two methods to close an active process. For example, in .NET, Process class has these two methods:
Releasing these resources take some time while tracking down the entire memory linked list/map to deallocate kernel objects’ resources.
Even .NET/java has its garbage collector to release “managed” memory for sure, kernel objects’ unmanaged resources are not always covered.
The following is a test app in .NET C#. We can compare CloseMainWindow() to Kill() using a Visual Studio add-on: Memory Profiler. In almost all cases, Kill() is faster but has less memory released by checking “root references” and “instance references” in real-time memory graph.