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

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

问题描述

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

解决方案

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

请参阅此IBM链接了解一些有趣的细节。 http://www-01.ibm.com/support/docview.wss uid = swg21326774



不幸的是,这是JVM的灰色地带之一;您对OS和JVM如何在彼此之间共享内存方面确实没有太多的控制权。将JVM看作需要运行一些内存的虚拟操作系统。您的父级操作系统和虚拟机都渴望资源,并希望尽可能多地使用获取的资源。从OS请求更多内存是一项耗时的操作,所以大多数JVM不会将内存释放回操作系统,即使它们不再需要时也是如此。

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



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

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?

解决方案

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.

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

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.

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

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天全站免登陆