Memory/Reference leak
-
I had an application handed to me that get the 'privilege' of fixing. This is a vb.net web app that is leaking memory like none other ( ok ok... it's leaking references to objects... fact is it's using up 2gig of memory when it should be using 40Meg). I'm having a heck of a time locating the source of the memory leak. It is a medium sized application ( about 30,000 lines of code ). Any Ideas on where I should start looking? I see the following lines of code repeated many times over... anything in here look like a memory leak to you?
Catch ta As Threading.ThreadAbortException Catch ex As Exception Throw New ApplicationException("Error Retrieving Area Types", ex) Finally If Not dbConnection Is Nothing Then If dbConnection.State = ConnectionState.Open Then _ dbConnection.Close() dbConnection.Dispose() dbConnection = Nothing End If End Try
// TODO: Write code.
-
I had an application handed to me that get the 'privilege' of fixing. This is a vb.net web app that is leaking memory like none other ( ok ok... it's leaking references to objects... fact is it's using up 2gig of memory when it should be using 40Meg). I'm having a heck of a time locating the source of the memory leak. It is a medium sized application ( about 30,000 lines of code ). Any Ideas on where I should start looking? I see the following lines of code repeated many times over... anything in here look like a memory leak to you?
Catch ta As Threading.ThreadAbortException Catch ex As Exception Throw New ApplicationException("Error Retrieving Area Types", ex) Finally If Not dbConnection Is Nothing Then If dbConnection.State = ConnectionState.Open Then _ dbConnection.Close() dbConnection.Dispose() dbConnection = Nothing End If End Try
// TODO: Write code.
Well it sounds good. If you could explain about your application then it would be much better for us to guide. other wise we can say just start from there.... Do one thing ... at the end of every event ,Procedure , Function write GC.Collect() this will collect the garbage which your system is not releasing. Secondly if you are using datasets and datatables then close them and set them to nothing after using them and right after that write GC.collect line to collect the garbage. I am sure this will help you out and will brought you back to the orignal memory.
-
Well it sounds good. If you could explain about your application then it would be much better for us to guide. other wise we can say just start from there.... Do one thing ... at the end of every event ,Procedure , Function write GC.Collect() this will collect the garbage which your system is not releasing. Secondly if you are using datasets and datatables then close them and set them to nothing after using them and right after that write GC.collect line to collect the garbage. I am sure this will help you out and will brought you back to the orignal memory.
I forgot to include some more info... I have tried using GC.Collect()... it does not seem to release the memory... it just promotes most of it to Gen2 ( Gen2 will show around 500MB after 2 hours of 14 users using the app ). So the references are still alive somewhere. I'll try closing the datasets. Datasets are used extensively throughout this application. The application is an asp.net interface to a large database. The biggest memory hog appears to be the forms for data entry. The forms have up to 70 different entry fields with some of them being drop down lists that are populated by the database. The drop down lists are cached in a hash table.
// TODO: Write code.
-
I forgot to include some more info... I have tried using GC.Collect()... it does not seem to release the memory... it just promotes most of it to Gen2 ( Gen2 will show around 500MB after 2 hours of 14 users using the app ). So the references are still alive somewhere. I'll try closing the datasets. Datasets are used extensively throughout this application. The application is an asp.net interface to a large database. The biggest memory hog appears to be the forms for data entry. The forms have up to 70 different entry fields with some of them being drop down lists that are populated by the database. The drop down lists are cached in a hash table.
// TODO: Write code.
well from your point I am quite afraid that you are might be using wrong queries. like to fetch ID from Table you are using select * from Table... and then you are puting them in a session to save them from fetching again. if it is true then dont do this. try to destroy maximum memory at server side MANUALLY ... instead of waiting like DataTable or Dataset.Dispose() GC.GetTotalMemory(True) GC.WaitForPendingFinalizers() GC.Collect means destory every thing... second thing is how many session variables you have and how many of them are datatables and datasets etc..... like asking for the variables which can consume unlimited space... Same with the application level variable.... hope this will help and let me know if nothing goes fine.... cheers......