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. Virtual memory usage of a process in c++

Virtual memory usage of a process in c++

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++jsonperformancehelp
12 Posts 3 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.
  • J John M Drescher

    GlobalMemoryStatus http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/globalmemorystatus.asp[^]

    John

    M Offline
    M Offline
    Manish_Home
    wrote on last edited by
    #3

    Thanx john :) Its a total size of virtual memory allocated to a process but i want virtual memory currently being used by the process. Do you knows anything about how can i get that information??

    Manish

    J 2 Replies Last reply
    0
    • M Manish_Home

      Thanx john :) Its a total size of virtual memory allocated to a process but i want virtual memory currently being used by the process. Do you knows anything about how can i get that information??

      Manish

      J Offline
      J Offline
      John M Drescher
      wrote on last edited by
      #4

      Total usedVirtual for a proccess = dwTotalVirtual - dwAvailVirtual;

      John

      M 1 Reply Last reply
      0
      • J John M Drescher

        Total usedVirtual for a proccess = dwTotalVirtual - dwAvailVirtual;

        John

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

        Thanx John :) I think that ll solve my querry...

        Manish

        1 Reply Last reply
        0
        • M Manish_Home

          Thanx john :) Its a total size of virtual memory allocated to a process but i want virtual memory currently being used by the process. Do you knows anything about how can i get that information??

          Manish

          J Offline
          J Offline
          John M Drescher
          wrote on last edited by
          #6

          If you can not get the information from GlobalMemoryStatus that you need you can also use VirtualQuery which will allow you to count all used memory blocks in a programs addresss space yourself. I actually have a need for both in the appilcations I write because of address space fragmentation the total amount of virtual memory free for a process may not be the amount of memory I can allocate given that I am allocating 16 to 60MB buffers. BTW - I can give you an example code on this when I get to work if you need.

          John

          M 1 Reply Last reply
          0
          • M Manish_Home

            Hi all, Can anyone knows how can i get virtual memory usage of a process in my c++ code,any api?? I am able to get physical memory usage of process in my code but not able to get information about virtual memory :doh: :doh: Any help??

            Manish

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #7

            And seehere[^] maybe its some helpful for you


            WhiteSky


            1 Reply Last reply
            0
            • J John M Drescher

              If you can not get the information from GlobalMemoryStatus that you need you can also use VirtualQuery which will allow you to count all used memory blocks in a programs addresss space yourself. I actually have a need for both in the appilcations I write because of address space fragmentation the total amount of virtual memory free for a process may not be the amount of memory I can allocate given that I am allocating 16 to 60MB buffers. BTW - I can give you an example code on this when I get to work if you need.

              John

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

              Hi John, I m satisfied with the virtual memory usage shown by GlobalMemoryStatus function previously i had used that function but it gives me a look of total virtual memory allocated to all running proceses. VirtualQuery needs Pointer to the base address of the region of pages to be queried from where i can get that? Coz i haven't allocated virtual memory by VirtualAlloc. As u said you have a sample example of ur own may be it will help a little. Thanx :)

              Manish

              J 1 Reply Last reply
              0
              • M Manish_Home

                Hi John, I m satisfied with the virtual memory usage shown by GlobalMemoryStatus function previously i had used that function but it gives me a look of total virtual memory allocated to all running proceses. VirtualQuery needs Pointer to the base address of the region of pages to be queried from where i can get that? Coz i haven't allocated virtual memory by VirtualAlloc. As u said you have a sample example of ur own may be it will help a little. Thanx :)

                Manish

                J Offline
                J Offline
                John M Drescher
                wrote on last edited by
                #9

                Do you still need this? I can email you this as it is too long to post here.

                John

                M 1 Reply Last reply
                0
                • J John M Drescher

                  Do you still need this? I can email you this as it is too long to post here.

                  John

                  M Offline
                  M Offline
                  Manish_Home
                  wrote on last edited by
                  #10

                  Thanx John! For the time i don't need to look on virtual memory usage but may be in future i required that. U can mail me at mmanish3214@rediffmail.com :)

                  Manish

                  J 1 Reply Last reply
                  0
                  • M Manish_Home

                    Thanx John! For the time i don't need to look on virtual memory usage but may be in future i required that. U can mail me at mmanish3214@rediffmail.com :)

                    Manish

                    J Offline
                    J Offline
                    John M Drescher
                    wrote on last edited by
                    #11

                    The problem with the code I promsed you is that it is part of a dll (that has over 50K lines of code) and uses a few other classes of the dll. For your purpose these are not necissary so giving you this code requires a little bit of cleanup which I have no problem doing however I am seriously behind a deadline at work. I have been working 12 hour days and although I really try to help others I really can't find the time. Sorry but I will get back to this I promise.

                    John

                    M 1 Reply Last reply
                    0
                    • J John M Drescher

                      The problem with the code I promsed you is that it is part of a dll (that has over 50K lines of code) and uses a few other classes of the dll. For your purpose these are not necissary so giving you this code requires a little bit of cleanup which I have no problem doing however I am seriously behind a deadline at work. I have been working 12 hour days and although I really try to help others I really can't find the time. Sorry but I will get back to this I promise.

                      John

                      M Offline
                      M Offline
                      Manish_Home
                      wrote on last edited by
                      #12

                      No probs John!!! I required that just for an alternative to my previous code,whenever u get time do that or evenif not posible dnt worry i got my problem solved.

                      Manish

                      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