Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Memory/Reference leak

Memory/Reference leak

Scheduled Pinned Locked Moved Visual Basic
csharpperformancehelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Adam Wimsatt
    wrote on last edited by
    #1

    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.

    R 1 Reply Last reply
    0
    • A Adam Wimsatt

      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.

      R Offline
      R Offline
      Rizwan Bashir
      wrote on last edited by
      #2

      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.

      A 1 Reply Last reply
      0
      • R Rizwan Bashir

        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.

        A Offline
        A Offline
        Adam Wimsatt
        wrote on last edited by
        #3

        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.

        R 1 Reply Last reply
        0
        • A Adam Wimsatt

          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.

          R Offline
          R Offline
          Rizwan Bashir
          wrote on last edited by
          #4

          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......

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups