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. C#
  4. How to free up memory - best method

How to free up memory - best method

Scheduled Pinned Locked Moved C#
winformsperformancetutorialquestion
2 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
    Albu Marius
    wrote on last edited by
    #1

    I have a program that uses 4 different user controls that are loaded in a panel depending on what the user wants to do. I add each UserControl to the Controls collection of the panel, but each time I fire the event that adds the UserControl to the panel the memory usage of my application increases although I clear the Controls collection. I have managed to stop this by implementing this method in each UserControl: public void Dispose() { Dispose(true); GC.SupressFinalize(this); } Is this the best method to handle this?

    P 1 Reply Last reply
    0
    • A Albu Marius

      I have a program that uses 4 different user controls that are loaded in a panel depending on what the user wants to do. I add each UserControl to the Controls collection of the panel, but each time I fire the event that adds the UserControl to the panel the memory usage of my application increases although I clear the Controls collection. I have managed to stop this by implementing this method in each UserControl: public void Dispose() { Dispose(true); GC.SupressFinalize(this); } Is this the best method to handle this?

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      You can invoke the Dispose all you want, but the system will take out the garbage when it deems time to do so. I am sure there has to be some way to coax it along :)

      "Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus

      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