Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. What is the Stack and Heap size of my Qt/C++ project?
Qt 6.11 is out! See what's new in the release blog

What is the Stack and Heap size of my Qt/C++ project?

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 3 Posters 7.9k Views 2 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.
  • VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by VRonin
    #2

    It's platform dependant. on Windows you can use:

    double getUsedMemoryMB()
    {
        PROCESS_MEMORY_COUNTERS pmc;
        GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc));
        return static_cast<double>(pmc.WorkingSetSize) / static_cast<double>(1024 * 1024);
    }
    

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    1 Reply Last reply
    6
    • MucipM Offline
      MucipM Offline
      Mucip
      wrote on last edited by
      #3

      @VRonin said in What is the Stack and Heap size of my Qt/C++ project?:

      #include <windows.h>

      Hi,
      Where is windows.h?! QT could not find it?...
      Regards,
      Mucip:)

      VRoninV 1 Reply Last reply
      0
      • MucipM Mucip

        @VRonin said in What is the Stack and Heap size of my Qt/C++ project?:

        #include <windows.h>

        Hi,
        Where is windows.h?! QT could not find it?...
        Regards,
        Mucip:)

        VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #4

        @Mucip said in What is the Stack and Heap size of my Qt/C++ project?:

        Where is windows.h?!

        Should be part of the windows compiler. What are you using?

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        0
        • MucipM Offline
          MucipM Offline
          Mucip
          wrote on last edited by
          #5

          @VRonin said in What is the Stack and Heap size of my Qt/C++ project?:

          Should be part of the windows compiler. What are you using?

          Hi,
          Win10 , QT Creator 4.7.0, QT 5.11.1 (MSVC 2015, 32 bit)

          Regards,
          Mucip:)

          JonBJ 1 Reply Last reply
          0
          • MucipM Mucip

            @VRonin said in What is the Stack and Heap size of my Qt/C++ project?:

            Should be part of the windows compiler. What are you using?

            Hi,
            Win10 , QT Creator 4.7.0, QT 5.11.1 (MSVC 2015, 32 bit)

            Regards,
            Mucip:)

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #6

            @Mucip
            You're in a severe mess if your MSVC doesn't have/find windows.h!

            MucipM 2 Replies Last reply
            1
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by VRonin
              #7

              Working example compiled with MSVC: http://rextester.com/HCD11597

              #include <iostream>
              #include <windows.h>
              #include <psapi.h>
              double getUsedMemoryMB()
              {
                  PROCESS_MEMORY_COUNTERS pmc;
                  GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc));
                  return static_cast<double>(pmc.WorkingSetSize) / static_cast<double>(1024 * 1024);
              }
              int main()
              {
                  std::cout << getUsedMemoryMB();
              }
              

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              MucipM 1 Reply Last reply
              7
              • JonBJ JonB

                @Mucip
                You're in a severe mess if your MSVC doesn't have/find windows.h!

                MucipM Offline
                MucipM Offline
                Mucip
                wrote on last edited by
                #8

                @JonB said in What is the Stack and Heap size of my Qt/C++ project?:

                You're in a severe mess if your MSVC doesn't have/find windows.h!

                Hi,
                I guess so...
                Shoul I install win 10 SDK???

                Regards,
                Mucip:)

                1 Reply Last reply
                0
                • JonBJ JonB

                  @Mucip
                  You're in a severe mess if your MSVC doesn't have/find windows.h!

                  MucipM Offline
                  MucipM Offline
                  Mucip
                  wrote on last edited by
                  #9

                  @JonB said in What is the Stack and Heap size of my Qt/C++ project?:

                  You're in a severe mess if your MSVC doesn't have/find windows.h!

                  Hi,
                  My situaiton like below...

                  0_1533206136131_4201cd15-61c9-4fde-9718-bea9451fa75b-resim.png

                  Regards,
                  Mucip:)

                  1 Reply Last reply
                  0
                  • VRoninV VRonin

                    Working example compiled with MSVC: http://rextester.com/HCD11597

                    #include <iostream>
                    #include <windows.h>
                    #include <psapi.h>
                    double getUsedMemoryMB()
                    {
                        PROCESS_MEMORY_COUNTERS pmc;
                        GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc));
                        return static_cast<double>(pmc.WorkingSetSize) / static_cast<double>(1024 * 1024);
                    }
                    int main()
                    {
                        std::cout << getUsedMemoryMB();
                    }
                    
                    MucipM Offline
                    MucipM Offline
                    Mucip
                    wrote on last edited by Mucip
                    #10

                    @VRonin said in What is the Stack and Heap size of my Qt/C++ project?:

                    #include <psapi.h>

                    Hi,
                    Finally I got it... Calital letter problem. It must be:

                    #include "Windows.h"
                    #include "Psapi.h"

                    Is returning number STACK or HEAP?... And what is the limit?...

                    Regards,
                    Mucip:)

                    JonBJ VRoninV 2 Replies Last reply
                    1
                    • MucipM Mucip

                      @VRonin said in What is the Stack and Heap size of my Qt/C++ project?:

                      #include <psapi.h>

                      Hi,
                      Finally I got it... Calital letter problem. It must be:

                      #include "Windows.h"
                      #include "Psapi.h"

                      Is returning number STACK or HEAP?... And what is the limit?...

                      Regards,
                      Mucip:)

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #11

                      @Mucip Windows filing system is case-insensitive, so no idea why you say you require capitals.

                      1 Reply Last reply
                      3
                      • MucipM Mucip

                        @VRonin said in What is the Stack and Heap size of my Qt/C++ project?:

                        #include <psapi.h>

                        Hi,
                        Finally I got it... Calital letter problem. It must be:

                        #include "Windows.h"
                        #include "Psapi.h"

                        Is returning number STACK or HEAP?... And what is the limit?...

                        Regards,
                        Mucip:)

                        VRoninV Offline
                        VRoninV Offline
                        VRonin
                        wrote on last edited by
                        #12

                        @Mucip said in What is the Stack and Heap size of my Qt/C++ project?:

                        Is returning number STACK or HEAP?

                        It's the sum of both

                        And what is the limit?

                        for 64bit systems the limit is just the hardware (how much RAM you have) for 32bit systems is the lower of the hardware memory and 4GB

                        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                        ~Napoleon Bonaparte

                        On a crusade to banish setIndexWidget() from the holy land of Qt

                        MucipM 1 Reply Last reply
                        1
                        • VRoninV VRonin

                          @Mucip said in What is the Stack and Heap size of my Qt/C++ project?:

                          Is returning number STACK or HEAP?

                          It's the sum of both

                          And what is the limit?

                          for 64bit systems the limit is just the hardware (how much RAM you have) for 32bit systems is the lower of the hardware memory and 4GB

                          MucipM Offline
                          MucipM Offline
                          Mucip
                          wrote on last edited by
                          #13

                          Dear @VRonin
                          Well, what about the 64K STACK limit I remember from old times?...

                          Regards,
                          Mucip:)

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved