Below is the output of the code on deb10
total used free shared buff/cache available
Mem: 7914 1789 4306 0 1819 5826
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7914 1789 4306 0 1819 5826
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7914 1791 4304 0 1819 5824
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7914 1791 4304 0 1819 5824
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7914 1793 4302 0 1819 5822
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7914 1793 4302 0 1819 5822
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7914 1795 4300 0 1819 5820
Swap: 0 0 0
.
.
.
Mem: 7914 4592 1502 0 1819 3022
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7914 4594 1500 0 1819 3020
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7914 4594 1501 0 1819 3021
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7914 4596 1499 0 1819 3019
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7914 4596 1499 0 1819 3019
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7914 4598 1497 0 1819 3017
Swap: 0 0 0
If you check the memory usage on "used" it is consuming ~4.5G by the end of the iteration.
Below is the output of the code on deb9.
total used free shared buff/cache available
Mem: 7923 1843 4128 4 1951 5776
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7923 1843 4128 4 1951 5776
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7923 1843 4128 4 1951 5776
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7923 1843 4128 4 1951 5776
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7923 1843 4128 4 1951 5776
Swap: 0 0 0
.
.
.
total used free shared buff/cache available
Mem: 7923 1870 4101 4 1952 5750
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7923 1870 4101 4 1952 5750
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7923 1870 4100 4 1952 5750
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7923 1870 4100 4 1952 5750
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7923 1870 4101 4 1952 5750
Swap: 0 0 0
total used free shared buff/cache available
Mem: 7923 1870 4100 4 1952 5750
Swap: 0 0 0
By the end of the iteration it is consuming ~1.8G
As we see from the output there is a huge memory consumption difference between deb9 and deb10. I would like to know why this is different, when the same code runs on different Debian machines (i.e. deb9 and deb10).