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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:39:23+00:00 2026-06-02T16:39:23+00:00

I am new to Linux and C++ and have a question about the memory

  • 0

I am new to Linux and C++ and have a question about the memory usage of my application.

My application processes a lot of real-time data, about 500 messages per second.

I use std::map to manage (i.e., insert and erase) all the messages. For example,

std::map<int, data_struct> m_map;

// when receive a new message, convert the message into a data structure
m_map.insert(std::pair<int, data_struct>(message.id, data));

// when need to erase a message
iter = m_map.find(id);
if (iter != m_map.end()) {
    m.map.erase(iter);
}

The size of the m_map is roughly about 2500, i.e., the application receives a lot new message at the beginning, then gradually need to erase messages. After about 10 seconds, it reaches a point that the number of new message received is about the same as the messages need to be erased.

My question is this, after about 20 minutes, in the Linux System Monitor, I noticed the memory my application uses is about 1GB. And it seems the size doubles every 20 minutes. Is this something normal, does the application really use that much memory? Am I missing something here?

Thanks.

  • 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-02T16:39:25+00:00Added an answer on June 2, 2026 at 4:39 pm

    If your program allocates and deallocates chunks of memory often, you get fragemtation – there is only so much the OS can do to make sure there are no gaps between the chunks of memory you have allocated. But generally, the memory usage resulting from this will plateau.

    If your program’s memory is continually increasing, you have a memory leak – either you are forgetting to delete objects (or call free() in the case of C-style allocations) or you are accumulating your objects in a container and forgetting to remove them.

    For finding missing delete calls, use valgrind!

    using valgrind to detect memory leaks is as simple as installing it using your favorite package manager and then running

    valgrind my_program
    

    Your program will run and when it’s finished, valgrind will dump a terribly detailed report of memory leaks and where they came from, including complete stack traces.

    valgrind is awesome.

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

Sidebar

Related Questions

I'm new to MySQL, and I have a question about the memory. I have
I'm new to Linux and have inherited keeping our single linux server running. It's
I am new to Rails and Linux and have installed RVM with sudo. sudo
I am new to EC2 and web development. Currently I have a Linux EC2
I'm new to PHP and have installed on Linux to boot (also a newbie).
I am new to both Qt and Linux C++ development (although I have many
I'm new to Makefile stuff and want to ask a question about Makefiles. Suppose
I need help about how to numeration text in file. I have also linux
I initially asked a question about how to create linux users via HTML (essentially
i have in a linux directory a lot of files, plain text with some

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.