0

In node.js there are libraries like V8 and process for getting the heap and malloc stats. Example:

const heapStats = v8.getHeapStatistics();
const heapInfo = process.memoryUsage();

console.log('Heap Total:', heapStats.heapTotal);
console.log('Heap Used:', heapStats.heapUsed);
console.log('Malloced Memory:', heapInfo.mallocedMemory);

Since both languages use an underlying C/C++ layer, is there any way to get these values in python for the current process?

Although using memory_info() in the psutil library we can get information about resident set size (rss), and physical memory used (vms), there aren't any attributes specific to heap and malloc.

We can also use tracemalloc to trace memory usage. However, I am not sure how to calculate the heap and malloc stats using these values.

0 Answers0