C++有java中的方法吗
Runtime.getRuntime().totalMemory()
Runtime.getRuntime().freeMemory()
我是这样用的
long mem0 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
/*
stuff to do
*/
long mem1 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
System.out.println(mem1-mem0);
查找程序使用的内存。这里有 C++ 中的任何类似物吗?
最佳答案
C++标准中没有规定,Windows下需要使用WinAPI For example this在 Linux 下,您需要使用库或调用系统调用。
关于c++ - 在 C++ 中获取总内存和可用内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15833740/