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

GC

Scheduled Pinned Locked Moved C#
performance
8 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.
  • D Offline
    D Offline
    devin123
    wrote on last edited by
    #1

    WIll GC only fress memory if there are other apps which needs more memory. If there is enough free space it will not free memory. Is it right.

    C D P 3 Replies Last reply
    0
    • D devin123

      WIll GC only fress memory if there are other apps which needs more memory. If there is enough free space it will not free memory. Is it right.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Gosh - didn't I just answer this ? In my experience, GC can be slow to occur if you don't force it, and yes, the thing that forces GC is the fact that your computer has no memory options left at all. Or you can force it yourself. This is a bad idea, you should just manage the items that you think can cause a problem. Basically, if you deal with large objects like bitmaps, you need to manage your own memory, just like you did in C++. Christian Graus - Microsoft MVP - C++

      D 1 Reply Last reply
      0
      • C Christian Graus

        Gosh - didn't I just answer this ? In my experience, GC can be slow to occur if you don't force it, and yes, the thing that forces GC is the fact that your computer has no memory options left at all. Or you can force it yourself. This is a bad idea, you should just manage the items that you think can cause a problem. Basically, if you deal with large objects like bitmaps, you need to manage your own memory, just like you did in C++. Christian Graus - Microsoft MVP - C++

        D Offline
        D Offline
        devin123
        wrote on last edited by
        #3

        Ok. But I can force GC by GC.Collect(). Thanks Devin.

        C 1 Reply Last reply
        0
        • D devin123

          Ok. But I can force GC by GC.Collect(). Thanks Devin.

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Yes, if you must. I would not recommend it though, you could hurt performance by causing the GC to run more often than it should. Just dispose of objects that you'd like collected. Christian Graus - Microsoft MVP - C++

          D 1 Reply Last reply
          0
          • C Christian Graus

            Yes, if you must. I would not recommend it though, you could hurt performance by causing the GC to run more often than it should. Just dispose of objects that you'd like collected. Christian Graus - Microsoft MVP - C++

            D Offline
            D Offline
            devin123
            wrote on last edited by
            #5

            Thanks this helped me a lot. Devin

            1 Reply Last reply
            0
            • D devin123

              WIll GC only fress memory if there are other apps which needs more memory. If there is enough free space it will not free memory. Is it right.

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              The GC runs on it's own internally managed schedule, not necessarily only when memory starts to run low. Other factors also influence when the GC occurs. If you release lots of small objects all over the managed heap, the GC will run earlier than scheduled so it can compact the memory to make room for larger objects and/or prevent memory fragmentation. This is only one small sample of how the GC manages memory collection. If you really want to learn the in's and out's about how the Framework manages memory, object creation/destruction, object lifetimes, how unmanged memory fits into scheme of managed memory, ..., check out this[^] article index on MSDN. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              1 Reply Last reply
              0
              • D devin123

                WIll GC only fress memory if there are other apps which needs more memory. If there is enough free space it will not free memory. Is it right.

                P Offline
                P Offline
                PaleyX
                wrote on last edited by
                #7

                As an aside I have found I can make much memory savings by reusing objects. Performance can go through the roof when doing that as well - or at least it did with me.

                P 1 Reply Last reply
                0
                • P PaleyX

                  As an aside I have found I can make much memory savings by reusing objects. Performance can go through the roof when doing that as well - or at least it did with me.

                  P Offline
                  P Offline
                  PaleyX
                  wrote on last edited by
                  #8

                  My apps performance improved, my own personal performance remained much the same :-O

                  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