java.exe 进程使用更多内存并且不会释放它 [英] java.exe process uses more memory and does not free it up

查看:40
本文介绍了java.exe 进程使用更多内存并且不会释放它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 java 应用程序,它在任何复杂执行之前处于空闲状态时,在堆中使用 23 MB,TaskManager 中的 java.exe 进程大小约为 194 MB.经过一些复杂的操作,java.exe的大小增长到500MB左右,堆大小也随之增长.通过调用 System.gc() 方法,在几次完整的 GC 后,堆大小减少回 23MB.但是 java.exe 的大小从大约 600MB 减少到大约 237MB,其中仍然有大约 43 MB 的数据.有没有办法减少这种情况?还是因为某些行为?

I have a java application which when in idle state before any complex executions, uses 23 MB in Heap and the java.exe process size in TaskManager was around 194 MB. After some complex operations, the size of java.exe grew up to around 500MB and the heap size also grew up. The Heap size is reduced back to 23MB after a few full GC by calling System.gc() method. But the size of java.exe reduced to around 237MB from around 600MB which still have around 43 MB of data in it. Is there a way to reduce this? Or is that due to some behavior?

推荐答案

这很正常,不用担心.JVM 在需要执行一些复杂的逻辑时会获取内存.当 java 处理完任务后,JVM 仍会将这些内存保留为保留空间,并且不会释放回操作系统.这种架构有助于提高性能,因为 JMV 不必再次从底层操作系统请求相同的内存.它仍然在您在 -Xmx JVM 参数中定义的范围内.

This is normal, don't worry. JVM acquires memory when it needs to execute some complex logic. When java is done processing the tasks the JVM will still keep that memory as a reserved space and is not released back to the OS. This architecture helps in performance because JMV does not have to request the same memory again from the underlying OS. It will still be within the range you define in -Xmx JVM parameter.

有关一些有趣的详细信息,请参阅此 IBM 链接.http://www-01.ibm.com/support/docview.wss?uid=swg21326774

See this IBM link for some interesting details. http://www-01.ibm.com/support/docview.wss?uid=swg21326774

不幸的是,这是 JVM 的灰色地带之一;对于操作系统和 JVM 如何在彼此之间共享内存,您真的没有太多控制权.将 JVM 视为需要一些内存才能运行的虚拟操作系统.您的父操作系统和 VM 都渴望资源,并希望尽可能多地保留获取的资源.从操作系统请求更多内存是一项耗时的操作,因此大多数 JVM 不会将内存释放回操作系统,即使它们不再需要它.

Unfortunately this is one of the grey areas of JVM; you really don't have much of a control on how OS and JVM share memory between each other. Think of JVM as a Virtual OS that requires some memory to run. Both your parent OS and the VM are hungry for resources and want to hang on to the acquired resources the as much memory as possible. Requesting for more memory from OS is a time consuming operation so most of the JVMs do not release the memory back to the OS even when they don't need it anymore.

有关内部 JVM 内存管理的更多详细信息,请参阅 Oracle 的这份白皮书.http://www.oracle.com/technetwork/java/javase/memorymanagement-whitepaper-150215.pdf

See this white paper from Oracle for more details on internal JVM memory management. http://www.oracle.com/technetwork/java/javase/memorymanagement-whitepaper-150215.pdf

我建议您先阅读 IBM 链接,然后您可以深入了解白皮书中解释的奇怪的内存世界.这两个链接都非常有用且有趣.

I would suggest you to read the IBM link first and then you can delve into the weird world of memory explained in the white paper. Both of these links are very informative and interesting.

这篇关于java.exe 进程使用更多内存并且不会释放它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆