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. How to get info of available heap memory?
Forum Updated to NodeBB v4.3 + New Features

How to get info of available heap memory?

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 4 Posters 1.2k 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
    MHermann
    wrote on last edited by MHermann
    #1

    Hi,
    I am running an application on Raspberry pi.
    Now I would like to be save that there is no OOM (out of memory).
    Is it possible to get info of application's available heap memory?

    Kind regards,
    MHermann

    J.HilkJ jeremy_kJ 2 Replies Last reply
    0
    • M MHermann

      Hi,
      I am running an application on Raspberry pi.
      Now I would like to be save that there is no OOM (out of memory).
      Is it possible to get info of application's available heap memory?

      Kind regards,
      MHermann

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @MHermann on raspberry pi there should be sysconf available

      but that only gives you the potential available memory

      you should listen to the bad alloc throws of your c++ application or, if you're compiling without exceptions, check for nullptr after the new call


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      1
      • M Offline
        M Offline
        MHermann
        wrote on last edited by
        #3

        @J-Hilk said in How to get info of available heap memory?:

        but that only gives you the potential available memory

        Potential available memory is not very helpful.
        I either need to know the used memory or the available memory.
        I want to print out the values in a logfile, so that I can check the logfiles after crash.

        So could be a way to do a (unnecessary) malloc, check the return and directly free it?
        But this solution seems not to be very nice...

        J.HilkJ 1 Reply Last reply
        0
        • M MHermann

          @J-Hilk said in How to get info of available heap memory?:

          but that only gives you the potential available memory

          Potential available memory is not very helpful.
          I either need to know the used memory or the available memory.
          I want to print out the values in a logfile, so that I can check the logfiles after crash.

          So could be a way to do a (unnecessary) malloc, check the return and directly free it?
          But this solution seems not to be very nice...

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @MHermann well I did some more research for you,

          seems like there is https://libstatgrab.org a cross platform c library, that gives feedback about the system status

          available memory free memory and used memory among them.


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          M 2 Replies Last reply
          3
          • M MHermann

            Hi,
            I am running an application on Raspberry pi.
            Now I would like to be save that there is no OOM (out of memory).
            Is it possible to get info of application's available heap memory?

            Kind regards,
            MHermann

            jeremy_kJ Offline
            jeremy_kJ Offline
            jeremy_k
            wrote on last edited by
            #5

            @MHermann said in How to get info of available heap memory?:

            Hi,
            I am running an application on Raspberry pi.

            The subtleties of any answer is also going to depend on the operating system, rather than merely the hardware platform.

            I either need to know the used memory or the available memory.

            As of when? Presuming a multitasking operating system, any information about the state of the system is likely stale for anything but the highest priority task in a hard realtime system.

            Asking a question about code? http://eel.is/iso-c++/testcase/

            M 1 Reply Last reply
            0
            • J.HilkJ J.Hilk

              @MHermann well I did some more research for you,

              seems like there is https://libstatgrab.org a cross platform c library, that gives feedback about the system status

              available memory free memory and used memory among them.

              M Offline
              M Offline
              MHermann
              wrote on last edited by
              #6

              @J-Hilk: Thank you very much. I will directly have a look at it.

              1 Reply Last reply
              1
              • jeremy_kJ jeremy_k

                @MHermann said in How to get info of available heap memory?:

                Hi,
                I am running an application on Raspberry pi.

                The subtleties of any answer is also going to depend on the operating system, rather than merely the hardware platform.

                I either need to know the used memory or the available memory.

                As of when? Presuming a multitasking operating system, any information about the state of the system is likely stale for anything but the highest priority task in a hard realtime system.

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

                @jeremy_k : I am using Raspbian Buster.
                I thought when it would be possible to output the used and available memory cyclic, then I could see if the used memory is steadily increasing.

                1 Reply Last reply
                0
                • J.HilkJ J.Hilk

                  @MHermann well I did some more research for you,

                  seems like there is https://libstatgrab.org a cross platform c library, that gives feedback about the system status

                  available memory free memory and used memory among them.

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

                  @J-Hilk said in How to get info of available heap memory?:

                  @MHermann well I did some more research for you,
                  seems like there is https://libstatgrab.org a cross platform c library, that gives feedback about the system status
                  available memory free memory and used memory among them.

                  I donwloaded statgrab, compiled and installed it.
                  Now I would like to use it in my source code, but I get following error message after compilation:

                  libstatgrab.so: file not recognized: file format not recognized
                  

                  I have to cross compile it for Raspbian buster.
                  I did following:

                  ./configure --host=arm-linux-gnueabihf  --prefix="/xxx/statgrab"
                  make
                  sudo make install
                  

                  But it seems to be wrong.
                  Any ideas what I did wrong?

                  J.HilkJ JonBJ 2 Replies Last reply
                  0
                  • M MHermann

                    @J-Hilk said in How to get info of available heap memory?:

                    @MHermann well I did some more research for you,
                    seems like there is https://libstatgrab.org a cross platform c library, that gives feedback about the system status
                    available memory free memory and used memory among them.

                    I donwloaded statgrab, compiled and installed it.
                    Now I would like to use it in my source code, but I get following error message after compilation:

                    libstatgrab.so: file not recognized: file format not recognized
                    

                    I have to cross compile it for Raspbian buster.
                    I did following:

                    ./configure --host=arm-linux-gnueabihf  --prefix="/xxx/statgrab"
                    make
                    sudo make install
                    

                    But it seems to be wrong.
                    Any ideas what I did wrong?

                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by
                    #9

                    @MHermann see here for a very similar question:
                    https://forum.qt.io/topic/109732/so-format-not-recognized

                    @JonB is very spot on with his post


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    M 1 Reply Last reply
                    0
                    • J.HilkJ J.Hilk

                      @MHermann see here for a very similar question:
                      https://forum.qt.io/topic/109732/so-format-not-recognized

                      @JonB is very spot on with his post

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

                      @J-Hilk: I saw this post already.
                      I got this info:

                      libstatgrab.so.10.0.2: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=2052c1fe0c5bbac74534fcf47c64bcd5f6e57164, with debug_info, not stripped
                      
                      1 Reply Last reply
                      0
                      • M MHermann

                        @J-Hilk said in How to get info of available heap memory?:

                        @MHermann well I did some more research for you,
                        seems like there is https://libstatgrab.org a cross platform c library, that gives feedback about the system status
                        available memory free memory and used memory among them.

                        I donwloaded statgrab, compiled and installed it.
                        Now I would like to use it in my source code, but I get following error message after compilation:

                        libstatgrab.so: file not recognized: file format not recognized
                        

                        I have to cross compile it for Raspbian buster.
                        I did following:

                        ./configure --host=arm-linux-gnueabihf  --prefix="/xxx/statgrab"
                        make
                        sudo make install
                        

                        But it seems to be wrong.
                        Any ideas what I did wrong?

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

                        @MHermann said in How to get info of available heap memory?:

                        I have to cross compile it for Raspbian buster.

                        I am not an expert, but isn't RPi arm64 architecture rather then x86/x64?

                        M 1 Reply Last reply
                        0
                        • JonBJ JonB

                          @MHermann said in How to get info of available heap memory?:

                          I have to cross compile it for Raspbian buster.

                          I am not an expert, but isn't RPi arm64 architecture rather then x86/x64?

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

                          @JonB: Yes , right.
                          I thought I can configure this by

                          ./configure --host=arm-linux-gnueabihf
                          

                          But that seems to be wrong.

                          JonBJ 1 Reply Last reply
                          0
                          • M MHermann

                            @JonB: Yes , right.
                            I thought I can configure this by

                            ./configure --host=arm-linux-gnueabihf
                            

                            But that seems to be wrong.

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

                            @MHermann
                            I wouldn't know, but I think this would explain the
                            libstatgrab.so: file not recognized: file format not recognized
                            message, if that is an x86/x64 file on an arm_64 platform, that was all.

                            M 1 Reply Last reply
                            0
                            • JonBJ JonB

                              @MHermann
                              I wouldn't know, but I think this would explain the
                              libstatgrab.so: file not recognized: file format not recognized
                              message, if that is an x86/x64 file on an arm_64 platform, that was all.

                              M Offline
                              M Offline
                              MHermann
                              wrote on last edited by MHermann
                              #14

                              @JonB: Yes. I think also that this is the problem.

                              I compiled it directly on the Raspberry Pi.
                              Now I can compile my application with statgrab.

                              1 Reply Last reply
                              1

                              • Login

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