That's quite platform-dependent, and even the notion of "memory usage" is 
pretty vague in a modern OS with virtual memory. The size of the malloc heap is 
usually the most useful, I've found; more generally it's the amount of address 
space that's unshared and mapped as writeable. Utilities like 'top' or macOS's 
Activity Monitor can show that as a live value you can monitor.

I'm not sure the Nim APIs above will be as accurate because I think they only 
report on memory allocated by Nim itself. If you're using any native libraries 
it probably won't include memory they allocate.

If you're on macOS (the only platform I know well), the `heap` tool is very 
useful. It reports a process's heap usage and breaks it down by the size of the 
blocks. It can also identify Objective-C, CoreFoundation and [some] C++ objects 
and group them by class name, which is useful if you're using system 
frameworks. Check the man page for details.

Reply via email to