如何在C语言中计算内存消耗
如何在C语言中计算内存消耗
这个问题已经有答案了:
在C中有没有计算内存消耗的方法。我查看了Stackoverflow上的其他答案,但它们并不令人满意。
类似于Java中的方法:
// Get the Java runtime Runtime runtime = Runtime.getRuntime(); // Run the garbage collector runtime.gc(); // Calculate the used memory long memory = runtime.totalMemory() - runtime.freeMemory(); System.out.println("Used memory is bytes: " + memory + "bytes"); System.out.println("Used memory is kilobytes: " + bytesTokilobytes(memory) +"kb");
admin 更改状态以发布 2023年5月20日