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

Memory Analysis

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

    ? I tried CMemoryState, without success.

    J R D 3 Replies Last reply
    0
    • R RadioOpa

      ? I tried CMemoryState, without success.

      J Offline
      J Offline
      John R Shaw
      wrote on last edited by
      #2

      I am not sure if there is a single function call that can give an answer to your question. This would have been a simple question before the advent of virtual memory, but that is no longer the case. If you want to know the physical memory available then you may have to experitment, but that limits you to the machine you are on. Write your programm in such a way that it can compensate for the lack of phisycal memory, or can inform the user if it can not. I am just saying that we no longer know the amount of memery available and you have to make sure that if it is not, your progam catches that problem before it crashes some bodies machine. INTP Every thing is relative...

      R 1 Reply Last reply
      0
      • J John R Shaw

        I am not sure if there is a single function call that can give an answer to your question. This would have been a simple question before the advent of virtual memory, but that is no longer the case. If you want to know the physical memory available then you may have to experitment, but that limits you to the machine you are on. Write your programm in such a way that it can compensate for the lack of phisycal memory, or can inform the user if it can not. I am just saying that we no longer know the amount of memery available and you have to make sure that if it is not, your progam catches that problem before it crashes some bodies machine. INTP Every thing is relative...

        R Offline
        R Offline
        RadioOpa
        wrote on last edited by
        #3

        Thanks John, it´s clear that new returns 0 if allocation failed. I´m just looking for a way of checking available memory before and after such operations. Due to the dynamic memory model in windows it may be impossible to get exact required data. Purpose is not implemeting it in a commercial application but memory usage demonstration to students. In DOS times ( a century ago ) ;) we had a similar function.

        1 Reply Last reply
        0
        • R RadioOpa

          ? I tried CMemoryState, without success.

          R Offline
          R Offline
          Ryan Binns
          wrote on last edited by
          #4

          Have a look at the GlobalMemoryStatus() function.

          Ryan

          "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

          1 Reply Last reply
          0
          • R RadioOpa

            ? I tried CMemoryState, without success.

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

            I doubt it, since freed memory does not automatically go right back to the pool of available memory. Windows' memory manager is a very complex beast.


            "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

            "There is no death, only a change of worlds." - Native American Proverb

            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