how to measure memory

This is a discussion on how to measure memory within the C++ Programming forums, part of the General Programming Boards category; Hi, I was wondering if there exists a function to measure memory on linux OS for a given c++ function. ...

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    172

    how to measure memory

    Hi,

    I was wondering if there exists a function to measure memory on linux OS for a given c++ function. So, what i have is a situation where a person claims that some function he/she wrote needs 20n words of memory to do something. however this function is quite complex and calls some other functions and so on. So i was hoping that there is a way to measure roughly if the memory statement is correct or not.

    So my question is: is something like that possible? Is there a function that i can call to see how much memory was consumed during its execution.

    Example

    Code:
    mem-measure_stat( functio(input) );
    
    cout << mem-measure_stat() << endl;
    where as a result I would get a memory consumption peak for this function

    thnx

    baxy

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    Before and after memory state?
    Statistics of Malloc - The GNU C Library

    Hook malloc and free to track usage while the function is being called.
    The GNU C Library
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Measure algorithm speed
    By ingenting in forum C++ Programming
    Replies: 4
    Last Post: 01-22-2010, 12:50 PM
  2. measure run time?
    By Tool in forum C Programming
    Replies: 14
    Last Post: 12-19-2009, 06:56 AM
  3. Measure time
    By anirban in forum C Programming
    Replies: 5
    Last Post: 06-12-2008, 03:53 AM
  4. How to measure memory consumption?
    By nysubmarine in forum C++ Programming
    Replies: 25
    Last Post: 06-27-2006, 03:40 AM
  5. So how does your computer measure up?
    By napkin111 in forum A Brief History of Cprogramming.com
    Replies: 27
    Last Post: 12-29-2002, 11:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21