Results 1 to 4 of 4

Thread: How to determine memory usage?

  1. #1
    Join Date
    Mar 2006
    Posts
    5
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question How to determine memory usage?

    Hi Folks,

    i would like to monitor the memory usage of my application from inside my application. Is there a way to query the ammount of allocated memory? A cross platform approach would fit the most, since it's designed to run on linux and on windows.
    Please let me know if you have any ideas.
    Thanks in advance!

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to determine memory usage?

    I cannot see a way to do this in a cross platform manner - perhaps there is a posix call that I'm not aware of - so I'm not saying that there is no way.

    For your Linux needs you can always rely on the /proc file system for finding this type of information. You find your PID using getpid.

  3. The following user says thank you to e8johan for this useful post:

    nopalot (11th February 2007)

  4. #3
    Join Date
    May 2006
    Location
    Germany
    Posts
    108
    Thanks
    2
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to determine memory usage?

    You could always overload the "new" operator and keep a log about how much memory was allocated.

  5. The following user says thank you to Methedrine for this useful post:

    nopalot (11th February 2007)

  6. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to determine memory usage?

    Quote Originally Posted by Methedrine View Post
    You could always overload the "new" operator and keep a log about how much memory was allocated.
    Not all memory is allocated using the new operator (and you'd have to do that for every class you use (templates might help)). It's better to redefine malloc() - it'll cover more cases. It won't be 100% foul proof though.

  7. The following user says thank you to wysota for this useful post:

    nopalot (12th February 2007)

Similar Threads

  1. Reducing CPU Usage
    By Kapil in forum Qt Programming
    Replies: 8
    Last Post: 3rd April 2011, 14:43
  2. How to determine available memory
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2007, 00:00
  3. saving a c string of variable length in a shared memory?
    By nass in forum General Programming
    Replies: 4
    Last Post: 3rd January 2007, 14:40
  4. vector memory allocation
    By TheKedge in forum General Programming
    Replies: 1
    Last Post: 23rd March 2006, 17:27
  5. Qt 4.1 Memory Leak
    By blackliteon in forum Qt Programming
    Replies: 14
    Last Post: 10th February 2006, 12:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.