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. C++ reading out memory specs [modified]

C++ reading out memory specs [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++game-devperformance
9 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.
  • F Offline
    F Offline
    Fatbuddha 1
    wrote on last edited by
    #1

    Hy folks, I have a little question of reading out the amount of memory that one can use for a program. I know there exists the method filling up the memory until you get an exception, but this isn't a nice way, right? So my question: Is there a way to read out memory specs in windows and other platforms as well? I was just wondering if one of you can thing of a nice platform independent function or approach to calculate the amount of memory available in the system. Also I am interested to find out the amount of processors to calculate the amount of threads for that platform. I am sorry for the leaking of knowledge. :sigh: Cheers

    You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)

    modified on Tuesday, March 24, 2009 11:41 AM

    M I 2 Replies Last reply
    0
    • F Fatbuddha 1

      Hy folks, I have a little question of reading out the amount of memory that one can use for a program. I know there exists the method filling up the memory until you get an exception, but this isn't a nice way, right? So my question: Is there a way to read out memory specs in windows and other platforms as well? I was just wondering if one of you can thing of a nice platform independent function or approach to calculate the amount of memory available in the system. Also I am interested to find out the amount of processors to calculate the amount of threads for that platform. I am sorry for the leaking of knowledge. :sigh: Cheers

      You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)

      modified on Tuesday, March 24, 2009 11:41 AM

      M Offline
      M Offline
      Michael Schubert
      wrote on last edited by
      #2

      Check out GlobalMemoryStatusEx() and the structure MEMORYSTATUSEX on MSDN.

      F 1 Reply Last reply
      0
      • M Michael Schubert

        Check out GlobalMemoryStatusEx() and the structure MEMORYSTATUSEX on MSDN.

        F Offline
        F Offline
        Fatbuddha 1
        wrote on last edited by
        #3

        Thanks. But this is just for windows, right? Or do you thing I have to check the op system before doing something. If that is possible. I am also interested in reading out the sys specs in general. For example the amount of processors to calculate how many threads I could start.. But thanks for pointing me in a direction. Cheers.

        You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)

        M 1 Reply Last reply
        0
        • F Fatbuddha 1

          Thanks. But this is just for windows, right? Or do you thing I have to check the op system before doing something. If that is possible. I am also interested in reading out the sys specs in general. For example the amount of processors to calculate how many threads I could start.. But thanks for pointing me in a direction. Cheers.

          You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)

          M Offline
          M Offline
          Michael Schubert
          wrote on last edited by
          #4

          Yes, only for Windows (unless you use something like Wine on Linux). There are articles about system info in this section: http://www.codeproject.com/KB/system/[^]

          F 1 Reply Last reply
          0
          • M Michael Schubert

            Yes, only for Windows (unless you use something like Wine on Linux). There are articles about system info in this section: http://www.codeproject.com/KB/system/[^]

            F Offline
            F Offline
            Fatbuddha 1
            wrote on last edited by
            #5

            Thanks you very much. But still either I am blind or just not seeing it, I can not find a nice function or a set of functions that return me system information. Actually, if I am allow to keep you busy, I am lacking of knowledge to detecting on which op I am on. I mean if I can detect what Os I am facing, it is straight forward to use your suggestion for windows and in Linux, I think, the specs are written in a file. Macs fights for their owns. :) But thanks for the great answers. Cheers

            You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)

            M D 2 Replies Last reply
            0
            • F Fatbuddha 1

              Thanks you very much. But still either I am blind or just not seeing it, I can not find a nice function or a set of functions that return me system information. Actually, if I am allow to keep you busy, I am lacking of knowledge to detecting on which op I am on. I mean if I can detect what Os I am facing, it is straight forward to use your suggestion for windows and in Linux, I think, the specs are written in a file. Macs fights for their owns. :) But thanks for the great answers. Cheers

              You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)

              M Offline
              M Offline
              Michael Schubert
              wrote on last edited by
              #6

              Fatbuddha 1 wrote:

              But still either I am blind or just not seeing it, I can not find a nice function or a set of functions that return me system information.

              Well, you have to read the articles and look at the code.

              Fatbuddha 1 wrote:

              I am lacking of knowledge to detecting on which op I am on.

              Do you mean which version of the OS? Like Win XP, 2000 etc.? Or Linux, MacOS, Windows?

              1 Reply Last reply
              0
              • F Fatbuddha 1

                Thanks you very much. But still either I am blind or just not seeing it, I can not find a nice function or a set of functions that return me system information. Actually, if I am allow to keep you busy, I am lacking of knowledge to detecting on which op I am on. I mean if I can detect what Os I am facing, it is straight forward to use your suggestion for windows and in Linux, I think, the specs are written in a file. Macs fights for their owns. :) But thanks for the great answers. Cheers

                You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)

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

                Fatbuddha 1 wrote:

                I mean if I can detect what Os I am facing...

                To my knowledge, there is not a platform-independent way of determining this. For Windows, check out GetVersionEx().

                "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                1 Reply Last reply
                0
                • F Fatbuddha 1

                  Hy folks, I have a little question of reading out the amount of memory that one can use for a program. I know there exists the method filling up the memory until you get an exception, but this isn't a nice way, right? So my question: Is there a way to read out memory specs in windows and other platforms as well? I was just wondering if one of you can thing of a nice platform independent function or approach to calculate the amount of memory available in the system. Also I am interested to find out the amount of processors to calculate the amount of threads for that platform. I am sorry for the leaking of knowledge. :sigh: Cheers

                  You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)

                  modified on Tuesday, March 24, 2009 11:41 AM

                  I Offline
                  I Offline
                  Iain Clarke Warrior Programmer
                  wrote on last edited by
                  #8

                  You can't compile a program and expect it to then be copied to any computer and run. So, it's not that bad to make a function in your own code that does different things depending on which operating system it is compiled for (you may be cross compiling for all I know) Ie:

                  DWORD HowManyMegaBytesDoIHave ()
                  {
                  #ifdef _WINDOWS
                  return ThatWindowsAPIFunction ();
                  #endif
                  #ifdef _MACOS9
                  etc

                  }

                  I hope that made sense. I'm pretty sure the windows one is real, no idea about the other, but they're just meant to illustrate. You'll have to the same #ifdef with the headers too. If you want one codebase to work identically on all OS's, then you'll have to scale back your desires a long way. Good luck, Iain.

                  In the process of moving to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!

                  F 1 Reply Last reply
                  0
                  • I Iain Clarke Warrior Programmer

                    You can't compile a program and expect it to then be copied to any computer and run. So, it's not that bad to make a function in your own code that does different things depending on which operating system it is compiled for (you may be cross compiling for all I know) Ie:

                    DWORD HowManyMegaBytesDoIHave ()
                    {
                    #ifdef _WINDOWS
                    return ThatWindowsAPIFunction ();
                    #endif
                    #ifdef _MACOS9
                    etc

                    }

                    I hope that made sense. I'm pretty sure the windows one is real, no idea about the other, but they're just meant to illustrate. You'll have to the same #ifdef with the headers too. If you want one codebase to work identically on all OS's, then you'll have to scale back your desires a long way. Good luck, Iain.

                    In the process of moving to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!

                    F Offline
                    F Offline
                    Fatbuddha 1
                    wrote on last edited by
                    #9

                    Sorry for the late answer. Of course you are right, what was I thinking?? Spend to much time on Java :). So to conclude either your way, or I simply provide a version of my prog for win and unix. This might be even the cleaner style. Thanks and have a nice weekend. Cheers

                    You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)

                    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