amit
amit

Reputation: 153

Even after cleanup the memory is not reducing

I have a C++ service that receives some events, those are written to a file after getting processed, till that point the messages are in memory, thus i have a big data structure storing the events.

Once the write is done, i do a cleanup of all the structures storing the memory, but even after that the memory is not coming down. I have all shared pointers, so eventually those should be cleanup some time even if i am missing something, but even that is not happening.

I ran valgrind on the service but it is not showing any memory leaks. I wanted to check if there is some way that i can check, where the memory is getting occupied?

Upvotes: 1

Views: 92

Answers (1)

David Schwartz
David Schwartz

Reputation: 182883

That's normal. Making memory free is almost always a pure efficiency loss and modern systems avoid it.

If the memory isn't needed for something else, the effort of making it free is obviously wasted. If it is needed for something else, it's still wasted because the OS just has to make it used again, undoing the work it did in making it free.

Modern systems directly transition memory from one use to another without making it free in the middle, unless they have no choice.

Upvotes: 1

Related Questions