gpt4 book ai didi

java - 如何获取已启动进程的内存使用情况

转载 作者:行者123 更新时间:2023-11-30 09:23:05 25 4
gpt4 key购买 nike


我尝试获取通过 Java 启动的进程的内存使用情况。
有人可以提示我如何为示例 Notepad.exe 执行此操作吗?

    // Memoryusage of the Java programm
Runtime runtime=Runtime.getRuntime();
total = runtime.totalMemory();
System.out.println("System Memory: " + total);

ProcessBuilder builder = new ProcessBuilder("notepad.exe");
Process p = builder.start();

感谢您的帮助!

最佳答案

这篇文章有你的答案 Java ProcessBuilder memory

引用最佳答案:

The new process runs outside the Java process that started it. Allocation of memory to the new process is managed by the operating system, as part of process management. The Java class ProcessBuilder, which provides an interface for starting and communicating with the new process, runs inside the Java process.

关于java - 如何获取已启动进程的内存使用情况,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16238121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com