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 / C++ / MFC
  4. Giving memory back to the system

Giving memory back to the system

Scheduled Pinned Locked Moved C / C++ / MFC
performancequestion
4 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.
  • N Offline
    N Offline
    nadiric
    wrote on last edited by
    #1

    I have an app that eats up a bunch of memory with objects (created with "new"), then releases it back to the system (using "delete"). I am monitoring the memory usage with taskmanager, and noticed something strange... the memory does not seem to be given back to the system. If I minimize the app, the memory is magically recovered by the system, and all is well, even after restoring the app. Is the memory actually given back, but taskmanager is just out of the loop until the minimize, or is the memory not released until the app is minimized? if so, am I supposed to call some sort of "flush" function to give it back? Thanks

    C D R 3 Replies Last reply
    0
    • N nadiric

      I have an app that eats up a bunch of memory with objects (created with "new"), then releases it back to the system (using "delete"). I am monitoring the memory usage with taskmanager, and noticed something strange... the memory does not seem to be given back to the system. If I minimize the app, the memory is magically recovered by the system, and all is well, even after restoring the app. Is the memory actually given back, but taskmanager is just out of the loop until the minimize, or is the memory not released until the app is minimized? if so, am I supposed to call some sort of "flush" function to give it back? Thanks

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      MS's memory manager is greedy. it hangs onto memory you've free'd in anticipation that you might need it again before your program exits. this makes subsequent allocations faster.

      image processing | blogging

      1 Reply Last reply
      0
      • N nadiric

        I have an app that eats up a bunch of memory with objects (created with "new"), then releases it back to the system (using "delete"). I am monitoring the memory usage with taskmanager, and noticed something strange... the memory does not seem to be given back to the system. If I minimize the app, the memory is magically recovered by the system, and all is well, even after restoring the app. Is the memory actually given back, but taskmanager is just out of the loop until the minimize, or is the memory not released until the app is minimized? if so, am I supposed to call some sort of "flush" function to give it back? Thanks

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        nadiric wrote:

        ...the memory does not seem to be given back to the system.

        Right, and this is perfectly normal behavior.

        nadiric wrote:

        ...but taskmanager is just out of the loop...

        TM is actually showing you the address space in use. This has nothing to do with the amount of that address space your program is actually using.


        "Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.

        "Judge not by the eye but by the heart." - Native American Proverb

        1 Reply Last reply
        0
        • N nadiric

          I have an app that eats up a bunch of memory with objects (created with "new"), then releases it back to the system (using "delete"). I am monitoring the memory usage with taskmanager, and noticed something strange... the memory does not seem to be given back to the system. If I minimize the app, the memory is magically recovered by the system, and all is well, even after restoring the app. Is the memory actually given back, but taskmanager is just out of the loop until the minimize, or is the memory not released until the app is minimized? if so, am I supposed to call some sort of "flush" function to give it back? Thanks

          R Offline
          R Offline
          Rick York
          wrote on last edited by
          #4

          An occasional call to _heapmin can be helpful.

          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