Thread: Virtual Memory utilization during run-time

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    10

    Virtual Memory utilization during run-time

    How can we dynamically determine 1) either in bytes or 2) percentage of total available memory used during the run-time of a C/C++ program.

    I am using an iterative computational & memory intensive algorithm. The memory / computational needs for the nth iteration can only be determined at the (n-1)th and nth iteration.

    Hence cannot pre-calculate the memory utilization. Any pointers will be helpful.

    Thanks,

  2. #2
    Registered User
    Join Date
    Jun 2004
    Posts
    277
    Quote Originally Posted by wots_guge
    How can we dynamically determine 1) either in bytes or 2) percentage of total available memory used during the run-time of a C/C++ program.

    I am using an iterative computational & memory intensive algorithm. The memory / computational needs for the nth iteration can only be determined at the (n-1)th and nth iteration.

    Hence cannot pre-calculate the memory utilization. Any pointers will be helpful.

    Thanks,
    I'm not sure, this might be a very stupid hint but... *nix has the command free wich seems to do it for you, obviusly it is the current free memmory of the system.

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    8
    What operating system?

    Windows use GetProcessMemoryInfo()

    Linux use /proc/self/stat or possibly other entries

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mutex and Shared Memory Segment Questions.
    By MadDog in forum Linux Programming
    Replies: 14
    Last Post: 06-20-2010, 04:04 AM
  2. Replies: 7
    Last Post: 02-06-2009, 12:27 PM
  3. Run time differences in Linux gcc versions
    By circuitbreaker in forum C++ Programming
    Replies: 7
    Last Post: 02-14-2008, 11:09 PM
  4. Replies: 4
    Last Post: 01-13-2008, 02:14 AM
  5. Replies: 1
    Last Post: 03-30-2004, 02:57 PM