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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. High Memory Usage

High Memory Usage

Scheduled Pinned Locked Moved C#
questionperformancetutorialannouncementlearning
6 Posts 4 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.
  • H Offline
    H Offline
    Heinz_
    wrote on last edited by
    #1

    Hi, I have a little (very small) app that use too much memory, how can i release resources that are not in use (loaded dll's that are no more necesary for example and all type of garbage that can be disposed) whithout closing my app of course? When i load a dll can i unload it when it's not needed and my app is in idle? I saw in a post a few days ago (and can't find it again) an instruction to unload resources when the app is close, if some one can provide me that line of code, this is for making sure i release resources. Thanx.

    S D 2 Replies Last reply
    0
    • H Heinz_

      Hi, I have a little (very small) app that use too much memory, how can i release resources that are not in use (loaded dll's that are no more necesary for example and all type of garbage that can be disposed) whithout closing my app of course? When i load a dll can i unload it when it's not needed and my app is in idle? I saw in a post a few days ago (and can't find it again) an instruction to unload resources when the app is close, if some one can provide me that line of code, this is for making sure i release resources. Thanx.

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      If you want to unload DLLs, you need to load them on a separate AppDomain. How did you conclude your app is using too much memory? Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      H 1 Reply Last reply
      0
      • H Heinz_

        Hi, I have a little (very small) app that use too much memory, how can i release resources that are not in use (loaded dll's that are no more necesary for example and all type of garbage that can be disposed) whithout closing my app of course? When i load a dll can i unload it when it's not needed and my app is in idle? I saw in a post a few days ago (and can't find it again) an instruction to unload resources when the app is close, if some one can provide me that line of code, this is for making sure i release resources. Thanx.

        D Offline
        D Offline
        Daniel Grunwald
        wrote on last edited by
        #3

        Make sure you are calling Dispose() on objects when you don't need them anymore (Controls, Pens, Brushes, Graphics, Bitmaps etc.). You cannot unload dlls (you would need to load them in separate appdomains which would create even more overhead). Note that Task Manager does not really show the memory usage of your app, it counts the memory used by the .NET Framework for every application, but in reality large parts of that memory are shared between multiple .NET processes.

        H 1 Reply Last reply
        0
        • S S Senthil Kumar

          If you want to unload DLLs, you need to load them on a separate AppDomain. How did you conclude your app is using too much memory? Regards Senthil _____________________________ My Blog | My Articles | WinMacro

          H Offline
          H Offline
          Heinz_
          wrote on last edited by
          #4

          With windows task manager (CTRL + ALT + DEL).

          1 Reply Last reply
          0
          • D Daniel Grunwald

            Make sure you are calling Dispose() on objects when you don't need them anymore (Controls, Pens, Brushes, Graphics, Bitmaps etc.). You cannot unload dlls (you would need to load them in separate appdomains which would create even more overhead). Note that Task Manager does not really show the memory usage of your app, it counts the memory used by the .NET Framework for every application, but in reality large parts of that memory are shared between multiple .NET processes.

            H Offline
            H Offline
            Heinz_
            wrote on last edited by
            #5

            Hi, you're right. Task manager does not really show the memory usage of my app. I tested it, i created a minimal app (a single and empty form) and it uses 10 MB of memory and a single and empty form does not require such amount of memory. My real app loads lots of resources, objects and dll's and it uses 15 MB, it's not a bad score at all! I'll try Dispose() for objects that are not useful anymore and support this method, thanx for your help.

            D 1 Reply Last reply
            0
            • H Heinz_

              Hi, you're right. Task manager does not really show the memory usage of my app. I tested it, i created a minimal app (a single and empty form) and it uses 10 MB of memory and a single and empty form does not require such amount of memory. My real app loads lots of resources, objects and dll's and it uses 15 MB, it's not a bad score at all! I'll try Dispose() for objects that are not useful anymore and support this method, thanx for your help.

              D Offline
              D Offline
              Dan Neely
              wrote on last edited by
              #6

              Heinz Suez wrote: Hi, you're right. Task manager does not really show the memory usage of my app. I tested it, i created a minimal app (a single and empty form) and it uses 10 MB of memory and a single and empty form does not require such amount of memory. My real app loads lots of resources, objects and dll's and it uses 15 MB, it's not a bad score at all! What it comes down to is that getting and returning memory from the system are very expensive operations. Since modern computers have alot more ram that was the case in the bad old days instead of repeatedly asking for small chunks and taking the hit from context switching with the OS every time .net asks for large chunks and holds onto the excess for a very long time unless the OS asks it to return any unused memory the app is holding onto.

              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