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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:25:05+00:00 2026-05-26T18:25:05+00:00

I wrote a small geoip lookup linux daemon in C++, and I’m getting two

  • 0

I wrote a small geoip lookup linux daemon in C++, and I’m getting two different results and I’m wondering why.

This is the source code: https://github.com/homer6/geoipd
I’ve checked it with valgrind for memory leaks and there weren’t any.

I have two web servers, both running the same Ubuntu image on Amazon EC2 and both behind a load balancer that is ensuring they each get about the same amount of traffic. I installed the daemon on both servers and I’ve let them run in production for a few days now.

Everything is working as expected, but the output from “ps aux” is slightly different for the two instances.

Server 1:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME
1004     28889  0.0  6.7 640288 517692 ?       Ss   Nov09   0:03

Server 2:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME
1004     16587  0.0  6.7 574752 517688 ?       Ss   Nov09   0:02

My question is two-parted:

  1. Why is there such a big difference in the virtual memory usage?
  2. Why is there a difference in the resident memory usage?

Thanks in advance…

UPDATE:
I remember checking the VM size when I first launched the processes. They were both at 574752 (or slightly under 575 MB) and they both had the same value.

  • 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-26T18:25:06+00:00Added an answer on May 26, 2026 at 6:25 pm

    From these 2 extra lines in server 1’s maps:

    7f003ed31000-7f003ed32000 ---p 00000000 00:00 0
    7f003ed32000-7f003f532000 rw-p 00000000 00:00 0
    

    it seems server 1 has allocated (but not initializing yet) memory for some object that server 2 has not yet. This is not necessarily bad; each kernel is most likely handling the memory properly, just different.

    You can run size geoip_server.o to make sure that the bss (uninitialized static data) is the same for the 2 daemons on each system:

    [ 18:10 root@hozbox / ]# size geoip_server.o
       text    data    bss         dec         hex       filename
       77727   1088772 200003752   201170251   bfd9d4b   geoip_server.o
    

    these numbers are made up as I do not have cmake 2.8.2 so I was unable to compile your code

    Additionally, you can cat /proc/meminfo on each system to see the specifics of how each kernel is managing its memory:

    [ 18:10 root@hozbox / ]# cat /proc/meminfo
    MemTotal:         443880 kB
    MemFree:            7792 kB
    Buffers:             788 kB
    Cached:            24468 kB
    SwapCached:        87512 kB
    Active:           189460 kB
    Inactive:         193316 kB
    Active(anon):     178604 kB
    Inactive(anon):   178956 kB
    Active(file):      10856 kB
    Inactive(file):    14360 kB
    Unevictable:           0 kB
    Mlocked:               0 kB
    HighTotal:             0 kB
    HighFree:              0 kB
    LowTotal:         443880 kB
    LowFree:            7792 kB
    SwapTotal:       4816892 kB
    SwapFree:        3856464 kB
    Dirty:                12 kB
    Writeback:             0 kB
    AnonPages:        305332 kB
    Mapped:             7812 kB
    Shmem:                60 kB
    Slab:              17628 kB
    SReclaimable:       8712 kB
    SUnreclaim:         8916 kB
    KernelStack:        1320 kB
    PageTables:         4592 kB
    NFS_Unstable:          0 kB
    Bounce:                0 kB
    WritebackTmp:          0 kB
    CommitLimit:     5038832 kB
    Committed_AS:    1910872 kB
    VmallocTotal:     570424 kB
    VmallocUsed:       32424 kB
    VmallocChunk:     524124 kB
    HardwareCorrupted:     0 kB
    HugePages_Total:       0
    HugePages_Free:        0
    HugePages_Rsvd:        0
    HugePages_Surp:        0
    Hugepagesize:       4096 kB
    DirectMap4k:       19392 kB
    DirectMap4M:      438272 kB
    

    This research paper from the University of Alberta on Understanding Memory is a very good read and may help explain the why a difference in VSZ for the same process running on 2 different systems can be normal.


    Some references and resources:

    procfs wiki page
    Runtime Memory Measurement
    Linux Kernel Documentation on /proc
    https://unix.stackexchange.com/questions/6301/how-do-i-read-from-proc-pid-mem-under-linux

    man proc:

    /proc/[pid]/maps
    A file containing the currently mapped memory regions
    and their access permissions. The format is:

    address           perms offset  dev   inode   pathname
    08048000-08056000 r-xp 00000000 03:0c 64593   /usr/sbin/gpm
    08056000-08058000 rw-p 0000d000 03:0c 64593   /usr/sbin/gpm
    08058000-0805b000 rwxp 00000000 00:00 0 
    40000000-40013000 r-xp 00000000 03:0c 4165    /lib/ld-2.2.4.so 
    40013000-40015000 rw-p 00012000 03:0c 4165    /lib/ld-2.2.4.so
    4001f000-40135000 r-xp 00000000 03:0c 45494   /lib/libc-2.2.4.so
    40135000-4013e000 rw-p 00115000 03:0c 45494   /lib/libc-2.2.4.so
    4013e000-40142000 rw-p 00000000 00:00 0 
    bffff000-c0000000 rwxp 00000000 00:00 0 
    

    where “address” is the address space in the process that it occupies,
    “perms” is a set of permissions,
    “offset” is the offset into the file/whatever, “dev” is the
    device (major:minor), and “inode” is the
    inode on that device. 0 indicates that no inode is associated with the
    memory region, as the case would be with BSS (uninitialized data).

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

Sidebar

Related Questions

I wrote a small sample of code in C# to capture selected text from
I wrote this small page and for some reason when I cilck on the
I wrote this small snippet to calculate Fibonacci numbers. It works well for numbers
I wrote this small game at http://amarnus.me/games/dodge . Now if you trying playing the
I wrote a small .NET applications that removes all line breaks in aspx/html/css code
I wrote two small C++ applications, one of which is an ActiveX container embedding
I wrote a small Shotgun app, however, the section of code that needs to
I am new to jquery . I wrote small piece of code <div id=tablediv><table><tr><td><h2>Select
I wrote a small app that allows me to compare two database schemas to
I wrote a small script that provided a URL (For example: code.google.com/ajax/123/1235/214) Would tell

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.