Consider an ASP.NET application with has a connection pool memory leak problem (where connections are not being closed correctly for example).
Does recycling the application pool clear the connection pool (thus allowing more connections to be made)?
If the connections are left in memory until the Garbage Collector removes them, does this happen when the application pool is restarted (or are/can they left beyond that)? I also understand the Garbage Collector could clean them up at anytime as well, but are they still in use and unable to be collected until a reset or application pool restart?
I'm reviewing a system where the end goal is obviously to have the code corrected to manage the connections correctly, and I'm trying to gain more of an understanding about the garbage collection/application pool process.
. NET's garbage collector manages the allocation and release of memory for your application. Each time you create a new object, the common language runtime allocates memory for the object from the managed heap.
In the common language runtime (CLR), the garbage collector (GC) serves as an automatic memory manager. The garbage collector manages the allocation and release of memory for an application. For developers working with managed code, this means that you don't have to write code to perform memory management tasks.
Application pool(s) recycle. The worker process hosting your applications can recycle due to a configuration change, time limit, idle timeout, excessive memory usage, and many other reasons. Application restart(s).
Yes, recycling the app pool kills and restarts the IIS process responsible for running your application. All resources are freed at this point, simply because the process is exiting.
If the process is never restarted and simply leaks handles, the garbage collector will eventually clean them up. However, it's likely that you'll run out of handles for whatever resource is leaking before this happens. This is why it's important to call Dispose() on these objects(preferably by the "using" pattern) so that the resources are freed as soon as the app is done with them and not when the garbage collector gets around to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With