Why linux build of the program consumes several times more RAM?
I work on a program. This program read a lot of data, processes it, creates data structures. I found out that on the test data I use, Mac and Windows version use approximately the same amount of RAM, around ~700Mb. On Linux it consumes around 2GB. I checked, and on Windows and Linux memory isn't compressed. What might be the culprit of such behavior? How could it be fixed?
UPDATE: Using malloc_trim helped. Now the RAM usage on Linux is in line with other platforms. Thanks to u/twitchax
UPDATE2: There's even easier way to fight this problem. You could set the MALLOC_TRIM_THRESHOLD_ environment variable to threshold value. It will be applied automatically, no need to litter your code with calls.