-3

My program loads data from files into structures

std::tr1::unordered_map< Key, Details*> 

and

std::tr1::unordered_map< KeyOuter, std::tr1::unordered_map<KeyInner, Details*>* >
Key := std::string | int | long long
Details : struct { Fields } ( sizeof >=40 bytes )

Periodically, my program reads new data from files, after that it recycles old structures. (A lot of new/delete operations)

In windows: memory usage after reloading data ~200mb.

Same files in CentOS: total memory usage after every reloading increases up to 1000mb (Memory Usage: 200->400->600->800->1000->1000->1000->1000)

No leaks were detected with vld and valngrind.

How solve this problem with memory in Linux?

1
  • Solved. Memory returned to os after malloc_trim() call
    – Jens
    Sep 24, 2013 at 13:23

1 Answer 1

2

This is not a problem. Linux is keeping the files you read earlier in its cache, so that if you need to read from them again you don't need HDD accesses.

This memory is NOT lost, it will be released as soon as any process requires more memory.

For further details, refer to http://www.linuxatemyram.com/ and similar topics on superuser.com.

Not the answer you're looking for? Browse other questions tagged or ask your own question.