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. Allocate memory

Allocate memory

Scheduled Pinned Locked Moved C / C++ / MFC
questionperformancehelp
9 Posts 5 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.
  • M Offline
    M Offline
    Maer727
    wrote on last edited by
    #1

    - I want to test what is the max memory space that I can allocate. (If I allocate more space than that, the machine will be halted or error will occur.) - Can you show me sample codes about that task? - Regards, Maer

    T T T 3 Replies Last reply
    0
    • M Maer727

      - I want to test what is the max memory space that I can allocate. (If I allocate more space than that, the machine will be halted or error will occur.) - Can you show me sample codes about that task? - Regards, Maer

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      The closest thing to what you want is to use GlobalMemoryStatus[Ex]. Note that in multitasking system the available memory can (and probably will) change between the call to GlobalMemoryStatus and actual allocation - so don't count on reliability of this technique. Tomasz Sowinski -- http://www.shooltz.com

      M 1 Reply Last reply
      0
      • M Maer727

        - I want to test what is the max memory space that I can allocate. (If I allocate more space than that, the machine will be halted or error will occur.) - Can you show me sample codes about that task? - Regards, Maer

        T Offline
        T Offline
        Todd Smith
        wrote on last edited by
        #3

        There's a tool that comes with VC that can simulate this if you're wanting to test your code under the extreme conditions (which is a very good thing btw).

        Todd Smith

        M 1 Reply Last reply
        0
        • M Maer727

          - I want to test what is the max memory space that I can allocate. (If I allocate more space than that, the machine will be halted or error will occur.) - Can you show me sample codes about that task? - Regards, Maer

          T Offline
          T Offline
          Tim Smith
          wrote on last edited by
          #4

          Man, this question is a lot harder than it sounds. The quick answer is 2GB if you don't use AWE. GlobalMemoryStatus is a start, but there are other issues. First would be what is the total number of pages a process is allowed to allocate. Second, even if you could in theory allocate tons and tons of memory, fragmentation of the address space will limit you to the total amount of memory. Tim Smith Descartes Systems Sciences, Inc.

          M 1 Reply Last reply
          0
          • T Tomasz Sowinski

            The closest thing to what you want is to use GlobalMemoryStatus[Ex]. Note that in multitasking system the available memory can (and probably will) change between the call to GlobalMemoryStatus and actual allocation - so don't count on reliability of this technique. Tomasz Sowinski -- http://www.shooltz.com

            M Offline
            M Offline
            Maer727
            wrote on last edited by
            #5

            - Thanks, Sowinski pal! - Your reply helps a lot. I still have a question. In MSDN (Ti: GlobalMemoryStatus), it is said, "The information returned by the GlobalMemoryStatus function is volatile.". I am a newbie of this field. I do not know what means "volatile". Can you show me an example? - Regards, Maer

            N 1 Reply Last reply
            0
            • M Maer727

              - Thanks, Sowinski pal! - Your reply helps a lot. I still have a question. In MSDN (Ti: GlobalMemoryStatus), it is said, "The information returned by the GlobalMemoryStatus function is volatile.". I am a newbie of this field. I do not know what means "volatile". Can you show me an example? - Regards, Maer

              N Offline
              N Offline
              Nish Nishant
              wrote on last edited by
              #6

              What 'volatile' implies is that the info returned by GlobalMemoryStatus cannot be guaranteed to be correct. You can try this by making successive calls and putting a Sleep(500) in between. You can be sure that you'll get different information. This is because by the time you get the info the memory status of the system would have changed. Nish Sonork ID 100.9786 voidmain

              M 1 Reply Last reply
              0
              • T Todd Smith

                There's a tool that comes with VC that can simulate this if you're wanting to test your code under the extreme conditions (which is a very good thing btw).

                Todd Smith

                M Offline
                M Offline
                Maer727
                wrote on last edited by
                #7

                - Thanks, Smith pal! - Your reply helps a lot. I still have two questions. - 1. What is the tool? Where can I find it? - 2. What means "btw"? - Can you help? - Regards, Maer

                1 Reply Last reply
                0
                • T Tim Smith

                  Man, this question is a lot harder than it sounds. The quick answer is 2GB if you don't use AWE. GlobalMemoryStatus is a start, but there are other issues. First would be what is the total number of pages a process is allowed to allocate. Second, even if you could in theory allocate tons and tons of memory, fragmentation of the address space will limit you to the total amount of memory. Tim Smith Descartes Systems Sciences, Inc.

                  M Offline
                  M Offline
                  Maer727
                  wrote on last edited by
                  #8

                  - Thanks, Smith pal! - Your reply helps a lot. I still have a question. What means "AWE"? - Can you help? - Regards, Maer

                  1 Reply Last reply
                  0
                  • N Nish Nishant

                    What 'volatile' implies is that the info returned by GlobalMemoryStatus cannot be guaranteed to be correct. You can try this by making successive calls and putting a Sleep(500) in between. You can be sure that you'll get different information. This is because by the time you get the info the memory status of the system would have changed. Nish Sonork ID 100.9786 voidmain

                    M Offline
                    M Offline
                    Maer727
                    wrote on last edited by
                    #9

                    - Thanks, Nish pal! - Your reply helps a lot. I still have a question. In MSDN (Ti: GlobalMemoryStatus), it is said, "// There are 150960 total Kbytes of paging file.". - I do not know what means "paging file". Can you show me an example? - Regards, Maer

                    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