Could you please expalin to me how “user space” memory is conted? in fact, it seems to me that only kernel memory is counted in this formula : TotalFreeMemory = MemFree + (Buffers + Cached + SwapCached) + SReclaimable.

]]>If your Linux is using a modern “ps” and/or kernel, this info is already available there.

AFAIK, AnonPages is memory mapped by applications.

Please note that tracking free memory down to MBytes is error-prone, I think. I’m not sure if all counters which are exported are an atomic snapshot of the system.

]]>What is the usage of AnonPages? is it normal that this bloc of memory grows like this?

Thanks

]]>I’am trtacking a memory leak in home gateway. I have read a lot of posts about memory management in linux, but things still be confusing for me. For exampal how to get total free memory; Is it MemFree + (Buffers + Cached + SwapCached) + SReclaimable?

]]>]]>

]]>

function get_primes7(n) {

if (n < 2) { return []; }

if (n == 2) { return [2]; }

var s = new Uint32Array(Math.ceil((n + 1) / 2 – 3));

for (var i = 3, j = 0; i < n + 1; i += 2) {

s[j++] = i;

}

var mroot = Math.floor(Math.sqrt(n));

var half = s.length;

var i = 0;

var m = 3;

while (m <= mroot) {

if (s[i]) {

var j = Math.floor((m*m-3)/2); // int div

s[j] = 0;

while (j < half) {

s[j] = 0;

j += m;

}

}

i = i + 1;

m = 2*i + 3;

}

var count = 0;

for (var x = 0; x < half; x++) {

if(s[x] !== 0)

count++;

}

var res = new Uint32Array(count + 1);

res[0] = 2;

for (var x = 0, j = 0; x < half; x++) {

if (s[x] !== 0) {

res[++j] = s[x];

}

}

return res;

}

var startTime = Date.now();

var periodTime = 10 * 1000

while ((Date.now() – startTime) < periodTime) {

var res = get_primes7(10000000);

console.log("Found " + res.length + " prime numbers.");

}

Surprising thing is that if we replace vars with let or const, performance considerable degrades.

]]>Therefore, we see nodejs perform quite similar to C++. ]]>