Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7814465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:12:07+00:00 2026-06-02T05:12:07+00:00

I am trying to measure memory consumption of a running program in Linux. I

  • 0

I am trying to measure memory consumption of a running program in Linux. I wrote a C program to allocate 1G memory, then use time to output its “Maximum resident set size”:

/usr/bin/time -f '%Uu %Ss %er %MkB %x %C' ./takeMem 1000000000

0.85u 0.81s 1.68r **3910016kB** 0 ./takeMem 1000000000

From man time, I should interpret that “Maximum resident set size” for such program take 3.9G memory although the program allocated only 1G memory. It does NOT make sense.

Can anybody known what happened to cause “Maximum resident set size” that high?

The C code is quite simple:

#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
    int memLength = atoi(argv[1]);
    fprintf(stderr, "Allocating %d memory...", memLength);
    unsigned char* p = new unsigned char[memLength];
    fprintf(stderr, "Done\n");                                                                                                                                                       
    while (true) {
        int i = rand() % memLength;
        char v = rand() % 256;
        p[i] = v;
    }

    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T05:12:08+00:00Added an answer on June 2, 2026 at 5:12 am

    I stumbled across this a while ago. It’s a bug in GNU time, values are 4 times too large, as it assumes a size in pages and converts it into kB, even though it is kB already in the first place.
    You might wanna check:

    http://groups.google.com/group/gnu.utils.help/browse_thread/thread/bb530eb072f86e18/83599c4828de175b

    http://forums.whirlpool.net.au/archive/1693957

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to measure the memory usage of a process (a java program)
I am trying to calculate the measure time of html 5 video. I use
I'm trying to use following code with System.nanoTime() to measure the elapsed time of
I'm trying to measure how long it takes read then encrypt some data (independently).
I am trying to use EMMA to measure coverage of some JUnit tests that
I am trying to measure short time intervals, in order few of milliseconds. This
I am trying to measure CPU time. It works great on Win 32, but
I'am trying to measure the performance of a computer vision program that tries to
I'm trying to measure, in a C# programm, the memory usage. I'd like to
I am trying to measure the time of raw_queries(...) , unsuccessfully so far. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.