i want to take container memory. i tried process.memoryUsage().heapUsed
, Object.keys(process.memoryUsage()).filter(key => key != "heapTotal").reduce((a, b) => process.memoryUsage()[b] + a, 0)
, os.freemem()
but it is giving more memory (like 50, 830) but my memory is 28 mb
Welcome @acarfy
To get the memory of the container you can read this file :
/sys/fs/cgroup/memory/memory.stat
But the data obtained will not be 100% accurate. The data present in the state tables are data calculated on an average, which are refreshed over a period of time to keep data consistent.
which? Screenshot by Lightshot
According to your screen, /sys/fs/cgroup/memory/memory.stat
refers to total_rss
memory is 22 mb
values are
cache 6238208
rss 100818944
rss_huge 0
mapped_file 966656
dirty 0
writeback 0
pgpgin 148227
pgpgout 122090
pgfault 312410
pgmajfault 200
inactive_anon 50630656
active_anon 50184192
inactive_file 1466368
active_file 4771840
unevictable 0
hierarchical_memory_limit 6442450944
total_cache 6238208
total_rss 100818944
total_rss_huge 0
total_mapped_file 966656
total_dirty 0
total_writeback 0
total_pgpgin 148227
total_pgpgout 122090
total_pgfault 312410
total_pgmajfault 200
total_inactive_anon 50630656
total_active_anon 50184192
total_inactive_file 1466368
total_active_file 4771840
total_unevictable 0
This only takes into account the processes in use from the heap, this is only part of the full project usage.
so i can’t give 100% container memory usage, i can only approximate values? but my memory 22 but it gives 98. it need to give decrease value (like 12, 15, 8)? (sorry for my english)
What do you mean by this ?
my memory is 22
it gives 98
you sad it gives < 22
? but
98 > 22?
This returns only the memory usage for the node process on which it is called, while the editor reports the memory usage of the container in the editor. There is a short delay between what is said (used) and what is displayed.