简体   繁体   English

Java 进程使用的总内存和堆大小

[英]Total memory used by Java process and heap size

I wrote an application using Spring Batch.我使用 Spring Batch 编写了一个应用程序。 I can see with VisualVM that the heap size is about 22 MB.我可以通过 VisualVM 看到堆大小约为 22 MB。 But, when I use Process Explorer (on Windows) to see how much memory is used by it, the difference is big (Private bytes - 71560K and Working Set - 80388K).但是,当我使用 Process Explorer(在 Windows 上)查看它使用了多少内存时,差异很大(私有字节 - 71560K 和工作集 - 80388K)。 How to explain this?这怎么解释? What are the other things that use this memory?使用这个内存的其他东西是什么?

Thanks谢谢

There is shared libraries, Thread's stack, perm gen, direct memory, memory mapped files.有共享库、线程堆栈、永久代、直接内存、内存映射文件。

However, the JVM allocates the maximum heap size on startup.但是,JVM 在启动时分配最大堆大小。 The amount used doesn't matter so much.使用的数量没有那么重要。

don't forget the native space (stack)!不要忘记本机空间(堆栈)! The heap only represents objects, threads/ primitives take up additional memory.堆只代表对象,线程/原语占用额外的内存。 Also AFAIK, once a process takes up memory, even though the contents may be garbage collected, it is at times not released back to the OS.同样 AFAIK,一旦进程占用内存,即使内容可能被垃圾收集,它有时也不会释放回操作系统。 Plus, I am not sure of VisualVM, but eclipse MAT only shows heap that is "current" (will not be garbage collected if GC was run at that point in time).另外,我不确定 VisualVM,但 Eclipse MAT 只显示“当前”的堆(如果当时运行 GC,则不会被垃圾收集)。 You may also want to look at jstat.您可能还想查看 jstat。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Java获取JVM堆总大小,已用内存 - How to get total JVM heap size, used memory using Java 在 Java 进程中出现 OutOfMemoryException,但 Used Heap 大约是 Used Size 的一半 - OutOfMemoryException in Java process, but Used Heap is about half of Used Size Java进程内存大小和堆大小之间的差异 - Difference between Java process memory size and Heap size Java堆大小内存 - Java Heap size Memory 如何查找 Java 堆大小和已用内存 (Linux)? - How to find Java Heap Size and Memory Used (Linux)? 具有恒定堆大小的Java进程在OS中分配越来越多的内存 - Java Process with constant heap size allocates more and more memory in OS 运行一些Java应用程序,其总堆大小内存设置为超过phisycal内存 - Running a few java applications with total heap size memory set to more than phisycal memory 哪个内存用于从 java - java 堆空间或操作系统内存运行的外部进程? - Which memory is used for external process run from java - java heap space or OS memory? 最大堆大小xmx如何影响Java中的内存分配/使用堆? - How does maximum heap size xmx influence the memory allocation / used heap in Java? Java进程的内存无限增长,但MemoryMXBean报告稳定的堆和非堆大小 - Java process's memory grows indefinitely, but MemoryMXBean reports stable heap and non-heap size
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM