Why does the memory consumption grows when using more threads on Linux? (C++)

c++, linux, memory, multithreading, openmp

Solution

A fair guess is that `delete` in Linux will cache released memory for future `new` requests, just as it does on Windows, but Linux has a cache per thread whereas Windows has a cache per process.

(More accurately, it would be the C++ runtime library that determines how such a cache works).

Problem

Program: I created a C++ calculation program for high volume of data, which could be run on 1 or more threads. (via config file) The program environment is the following: C++, OpenMp, Redhat-x64, malloc/free Results on Linux: - When I run it on 1 thread, process size is 177 MB. - When I run it on 2 threads, process size is 317 MB. - When I run it on 4 threads, process size is 600 MB. Results on Windows: - Process size still the same regardless the number of threads used, 110MB. Question: Why does the memory consumption grows when using more threads on Linux?

Original source