我们遇到了一个 JVM 的问题,它使用了比 max -Xmx 更多的东西。
我们正在使用 -Xmx2048,它目前正在使用 17GB 的操作系统内存。
我意识到 JVM 可以使用超过最大堆的使用量,但我们的使用量要多 15GB,这似乎很疯狂。
顶部转储如下所示:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
30477 root 20 0 22.683g 0.017t 18536 S 0.7 29.1 27:43.44 java -Xmx2048M -Xms1024M -XX:MaxPermSize=256M -XX:ReservedCodeCacheSize=128M ....
(注意它使用的是 0.017TB 或 17GB)。
我尝试过使用 jmap 进行调试:
sudo jmap -J-d64 -heap 30477
Attaching to process ID 30477, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.75-b04
using thread-local object allocation.
Parallel GC with 8 thread(s)
Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 2147483648 (2048.0MB)
NewSize = 1310720 (1.25MB)
MaxNewSize = 17592186044415 MB
OldSize = 5439488 (5.1875MB)
NewRatio = 2
SurvivorRatio = 8
PermSize = 21757952 (20.75MB)
MaxPermSize = 268435456 (256.0MB)
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
PS Young Generation
Eden Space:
capacity = 316145664 (301.5MB)
used = 150828136 (143.8409194946289MB)
free = 165317528 (157.6590805053711MB)
47.708431009827166% used
From Space:
capacity = 20447232 (19.5MB)
used = 3406624 (3.248809814453125MB)
free = 17040608 (16.251190185546875MB)
16.660563151041668% used
To Space:
capacity = 21495808 (20.5MB)
used = 0 (0.0MB)
free = 21495808 (20.5MB)
0.0% used
PS Old Generation
capacity = 716177408 (683.0MB)
used = 516302952 (492.3848648071289MB)
free = 199874456 (190.6151351928711MB)
72.09148825873044% used
PS Perm Generation
capacity = 56098816 (53.5MB)
used = 55842840 (53.255882263183594MB)
free = 255976 (0.24411773681640625MB)
99.54370516482915% used
15065 interned Strings occupying 1516808 bytes.
还有……
sudo jmap -J-d64 -permstat 30477
Attaching to process ID 30477, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.75-b04
finding class loader instances ..done.
computing per loader stat ..done.
please wait.. computing liveness...liveness analysis may be inaccurate ...
class_loader classes bytes parent_loader alive? type
<bootstrap> 1908 11793728 null live <internal>
0x0000000780b97590 1 1880 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b99b28 1 1880 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b96cb0 1 1880 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780113ca0 1 1880 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b97c90 1 3048 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780114458 1 3048 null dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b892b0 1 3024 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b989a8 1 1880 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780019cf0 7731 44085000 0x0000000780019d40 live sun/misc/Launcher$AppClassLoader@0x0000000770239a20
0x0000000780113f10 1 3152 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780aa8918 1 1880 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780114008 1 3040 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b7a8b8 1 3024 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780d236d0 1 3048 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780019d40 207 1327296 null live sun/misc/Launcher$ExtClassLoader@0x00000007701eb8b8
0x0000000780113e28 1 1880 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x00000007801140b0 1 3064 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x000000078dc814f8 1 3024 null dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b8abf8 1 3208 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b990a8 1 3048 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780114130 1 1904 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b98010 1 1880 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x00000007801141b0 1 1880 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780113620 27 86320 0x0000000780019cf0 live org/apache/tapestry5/internal/plastic/PlasticClassLoader@0x000000077181b058
0x0000000780114418 1 3064 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b98d28 1 3048 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b89270 1 3024 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780113ed0 1 3024 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b97910 1 1880 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b997a8 1 1880 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b96930 1 3048 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780d36d38 1 3024 0x0000000780019d40 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b99ea8 1 1880 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780bddff8 1 1880 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780a63ca0 1 3024 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780114048 1 3048 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780113fc8 1 3024 null dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780113de8 1 3072 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b7afb8 1 3040 null dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780113e68 1 1904 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b7ac38 1 1880 null dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780113d58 1 3064 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x00000007801140f0 1 3280 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b98628 1 3048 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x000000078088f900 0 0 0x0000000780019cf0 dead java/util/ResourceBundle$RBClassLoader@0x00000007709cda40
0x0000000780b99428 1 1880 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780d28ba0 1 3024 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b97030 1 3048 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780114170 1 3064 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x00000007801143d8 1 3048 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780114240 1 1880 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
0x0000000780b8af60 1 3104 0x0000000780019cf0 dead sun/reflect/DelegatingClassLoader@0x0000000770059770
total = 53 9921 57418080 N/A alive=4, dead=49 N/A
该应用程序是一个 Play 应用程序,我知道它使用类加载器会做一些奇怪的事情,但我认为 -permstat 应该考虑到这一点,所以我很难过。
有什么想法吗?
约翰
最佳答案
请注意,堆区(以 Xmx 为界)只是 JVM 进程的一部分。
JVM占用的内存基本上是以下的总和:
也许还有更多,你可以通过谷歌搜索找到它:)
因此,您必须检查所有这些区域以确保正在消耗内存。
我敢打赌,您有简单的线程泄漏 - 数千个线程会占用大量内存(正如我所说,假设每个线程 1MB,10000 个线程对应于 10GB 内存)。您可以简单地进行线程转储 (jstack -l > dumpfile.txt) 以查看是否存在问题。
当然也可以是外部库使用 native 缓冲区或 JNI,但可能性较小。
关于java - JVM 使用的堆比最大堆多很多,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29283447/
我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div
我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看rubyzip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d
类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc
很好奇,就使用rubyonrails自动化单元测试而言,你们正在做什么?您是否创建了一个脚本来在cron中运行rake作业并将结果邮寄给您?git中的预提交Hook?只是手动调用?我完全理解测试,但想知道在错误发生之前捕获错误的最佳实践是什么。让我们理所当然地认为测试本身是完美无缺的,并且可以正常工作。下一步是什么以确保他们在正确的时间将可能有害的结果传达给您? 最佳答案 不确定您到底想听什么,但是有几个级别的自动代码库控制:在处理某项功能时,您可以使用类似autotest的内容获得关于哪些有效,哪些无效的即时反馈。要确保您的提
假设我做了一个模块如下:m=Module.newdoclassCendend三个问题:除了对m的引用之外,还有什么方法可以访问C和m中的其他内容?我可以在创建匿名模块后为其命名吗(就像我输入“module...”一样)?如何在使用完匿名模块后将其删除,使其定义的常量不再存在? 最佳答案 三个答案:是的,使用ObjectSpace.此代码使c引用你的类(class)C不引用m:c=nilObjectSpace.each_object{|obj|c=objif(Class===objandobj.name=~/::C$/)}当然这取决于
我正在尝试使用ruby和Savon来使用网络服务。测试服务为http://www.webservicex.net/WS/WSDetails.aspx?WSID=9&CATID=2require'rubygems'require'savon'client=Savon::Client.new"http://www.webservicex.net/stockquote.asmx?WSDL"client.get_quotedo|soap|soap.body={:symbol=>"AAPL"}end返回SOAP异常。检查soap信封,在我看来soap请求没有正确的命名空间。任何人都可以建议我
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po