Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
他们显示的同一个程序的内存使用情况是如此不同。有没有其他东西会消耗内存?
是的。Java 以大块的形式分配其内存并在内部管理这些块(作为单个进程)。linux top 命令仅将 JVM 视为一个整体(而不是内部内存使用情况)。为此,请使用 jconsole;它显示有多少可用内存(在 JVM 内)。
顺便说一句,您还可以从 OperatingSystemMXBean 获取 JVM 操作系统进程的总内存使用量。