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 6902667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:49:36+00:00 2026-05-27T07:49:36+00:00

what ‘man top’ said is: RES = CODE + DATA q: RES — Resident

  • 0

what ‘man top’ said is: RES = CODE + DATA

q: RES -- Resident size (kb)
The non-swapped physical memory a task has used.
RES = CODE + DATA.

r: CODE -- Code size (kb)
The amount of physical memory devoted to executable code, also known as the 'text        resident set' size or TRS.

s: DATA -- Data+Stack size (kb)
The amount of physical memory devoted to other than executable code, also known as the   'data >resident set' size or DRS.

what when i run ‘top -p 4258’,i get the following:

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  CODE DATA COMMAND
258 root      16   0  3160 1796 1328 S  0.0  0.3   0:00.10  476  416 bash

1796 != 476+416

why?

ps:
linux distribution:

linux-iguu:~ # lsb_release -a
LSB Version:    core-2.0-noarch:core-3.0-noarch:core-2.0-ia32:core-3.0-ia32:desktop-3.1-ia32:desktop-3.1-noarch:graphics-2.0-ia32:graphics-2.0-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: SUSE LINUX
Description:    SUSE Linux Enterprise Server 9 (i586)
Release:        9
Codename:       n/a

kernel version:

linux-iguu:~ # uname -a
Linux linux-iguu 2.6.16.60-0.21-default #1 Tue May 6 12:41:02 UTC 2008 i686 i686 i386 GNU/Linux
  • 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-05-27T07:49:37+00:00Added an answer on May 27, 2026 at 7:49 am

    I’ll explain this with the help of an example of what happens when a program allocates and uses memory. Specifically, this program:

    #include <stdio.h>
    #include <stdlib.h>
    #include <errno.h>
    #include <string.h>
    
    int main(){
    
            int *data, size, count, i;
    
            printf( "fyi: your ints are %d bytes large\n", sizeof(int) );
    
            printf( "Enter number of ints to malloc: " );
            scanf( "%d", &size );
            data = malloc( sizeof(int) * size );
            if( !data ){
                    perror( "failed to malloc" );
                    exit( EXIT_FAILURE );
            }
    
            printf( "Enter number of ints to initialize: " );
            scanf( "%d", &count );
            for( i = 0; i < count; i++ ){
                    data[i] = 1337;
            }
    
            printf( "I'm going to hang out here until you hit <enter>" );
            while( getchar() != '\n' );
            while( getchar() != '\n' );
    
            exit( EXIT_SUCCESS );
    }
    

    This is a simple program that asks you how many integers to allocate, allocates them, asks how many of those integers to initialize, and then initializes them. For a run where I allocate 1250000 integers and initialize 500000 of them:

    $ ./a.out
    fyi: your ints are 4 bytes large
    Enter number of ints to malloc: 1250000
    Enter number of ints to initialize: 500000
    

    Top reports the following information:

      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  SWAP CODE DATA COMMAND
    <program start>
    11129 xxxxxxx   16   0  3628  408  336 S    0  0.0   0:00.00 3220    4  124 a.out
    <allocate 1250000 ints>
    11129 xxxxxxx   16   0  8512  476  392 S    0  0.0   0:00.00 8036    4 5008 a.out
    <initialize 500000 ints>
    11129 xxxxxxx   15   0  8512 2432  396 S    0  0.0   0:00.00 6080    4 5008 a.out
    

    The relevant information is:

                              DATA CODE  RES VIRT
    before allocation:         124    4  408 3628
    after 5MB allocation:     5008    4  476 8512
    after 2MB initialization: 5008    4 2432 8512
    

    After I malloc’d 5MB of data, both VIRT and DATA increased by ~5MB, but RES did not. RES did increase after I touched 2MB of the integers I allocated, but DATA and VIRT stayed the same.

    VIRT is the total amount of virtual memory used by the process, including what is shared and what is over-committed. DATA is the amount of virtual memory used that isn’t shared and that isn’t code-text. I.e., it is the virtual stack and heap of the process. RES is not virtual: it is a measurment of how much memory the process is actually using at that specific time.

    So in your case, the large inequality CODE+DATA < RES is likely the shared libraries included by the process. In my example (and yours), SHR+CODE+DATA is a closer approximation to RES.

    Hope this helps.
    There’s a lot of hand-waving and voodoo associated with top and ps. There are many articles (rants?) online about the descrepancies. E.g., this and this.

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

Sidebar

Related Questions

I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a reasonable size flat file database of text documents mostly saved in
I was writing code for dragging mechanism which invokes to wait for small period
string formIdList = 8256, 8258, 8362, 8120, 8270, 8271, 8272, 8273, 8257, 8279, 8212,
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
I am trying to create a RegEx expression that will successfully parse the following

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.