如何监控Myeclipse的虚拟机监控内存

WebLogic10内存溢出及设置虚拟内存方法 -
烏。 - ITeye技术网站
博客分类:
调整weblogic虚拟内存暂时我知道的有两种方法:
改正方法:-Xms256m -Xmx256m -XX:MaxNewSize=256m -XX:MaxPermSize=256m
更改的方式如下:
F:\bea\user_projects\domains\base_domain\bin 对文件:startWeblogic.cmd中增加:
@REM ----------------------------------------------------------------------
@REM Reset the memory configuration ()
@REM ----------------------------------------------------------------------
set MEM_ARGS=-Xms1024m -Xmx1024m -XX:MaxPermSize=512m
如若采用的是eclipse product模式,weblogic server在elipse中启动的话,还要修改eclipse中的配置:
进到eclipse中的eclipse.ini中,修改如下:
--launcher.XXMaxPermSize 512m -vmargs -Xms2048m -Xmx2048m
与weblogic中startWeblogic修改的配置一样。
更改的方式如下:
F:\bea\user_projects\domains\base_domain\bin 对文件:setDomainEnv.cmd中配置:
MEM_ARGS="-Xms32m -Xmx200m -XX:MaxPermSize=128m"
  -Xms:内存初始值
  -Xmx:内存最大值(不要超过内存的80%)
  MaxPermSize:PermGen(Class和Meta存放区域)区域内存最大值。
  可调整为:
  MEM_ARGS="-Xms512m -Xmx512m -XX:MaxPermSize=256m"
-XX:MaxPermSize改为256或512
下面这一段是关于对第一种方法另一种配置解释:
对 JRockit JVM优化
Setting the Nursery
尽力使Nursery最够大,来减少GC停顿时间。最大最好不要超过最大Heap 95%。
Setting minimum heap size
BEA 推荐这个值最好等于最大的heap。
Setting maximum heap size
Heap最大值,当然越大越好。
Setting garbage collection
-Xgc: parallel
Performs adaptive optimizations as early as possible in the Java application run.
-XXaggressive:memory
Setting the New generation heap size
-XX:NewSize
默认 NewSize大小是Heap的四分之一,类似Nursery,尽量设置大点减少GC停顿时间。
Setting the maximum New generation heap size
-XX:MaxNewSize
设置 New Generation heap 最大值.
Setting New heap size ratios
-XX:SurvivorRatio
在Sun generation分为3个区域,一个Edgn和两个survivors。该值是设置Edgn与Surviors的比例。最好设置为8.
Setting minimum heap size
推荐这个值最好等于最大的heap。
Setting Big Heaps and Intimate Shared Memory
-XX:+UseISM -XX:+AggressiveHeap
Setting maximum heap size
Heap最大值,当然越大越好。
直接修改user_projectsdomainsbase_domainbin下的startWebLogic.cmd文件,找到:
@REM JAVA_OPTIONS
- Java command-line options for running the server. (These
will be tagged on to the end of the JAVA_VM and
@REM JAVA_OPTIONS - Java command-line options for running the server. (These @REM will be tagged on to the end of the JAVA_VM and @REM MEM_ARGS)
在后面追加以下代码,启动配置信息即可生效。
$ java -XX:NewSize=128m -XX:MaxNewSize=128m -XX:SurvivorRatio=8 -Xms512m -Xmx512m
内存溢出的原因:
PermGen space的全称是Permanent Generation space,是指内存的永久保存区域OutOfMemoryError: PermGen space从表面上看就是内存溢出,解决方法也一定是加大内存。说说为什么会内存溢出:这一部分用于存放Class和Meta的信息,Class在被 Load的时候被放入PermGen space区域,它和和存放Instance的Heap区域不同,GC(Garbage Collection)不会在主程序运行期对PermGen space进行清理,所以如果你的APP会LOAD很多CLASS的话,就很可能出现PermGen space错误。这种错误常见在web服务器对JSP进行pre compile的时候。
除了设置参数时,最最重要的是在创建domains时选择JDK时应该选择bea的JRocke,不要选择sun的JDK(sun JDK的垃圾回收机制被占用,无法回收),所以为了不当机,最好选择bea的。
浏览 15126
浏览: 75691 次
来自: 郴州
如何在java Web项目中开发WebService接口,地址 ...
wsdl:service name=&Hello 太 ...
&div class=&quote_title ...
你好,如果远程调用webservice,服务商提供的参数是个对 ...
很好 适合初学者JAVA自带监控工具的介绍
简单介绍java自带的监控工具,这些监控工具是jdk5.0以上才有。
用来显示本地的java进程,以及进程号。
我们可以通过它来查看我们到底启动了几个java进程.
jps也可以列出远程服务器的java进程(远程服务需提供jstatd服务,采用rmi协议,默认链接端口1099),通常没人这么干。
==============================================
可以输出并修改运行时的java进程的参数(JVM参数和Java System属性)
jinfo& pid 会打印出详细的jvm运行参数和Java System属性。
此命令内容较多。而且输出的也稍慢。不过可以用以下命令来打印出你所关注的参数。
jinfo -flag MaxPermSize pid 该命令查看某个进程的MaxPermSize(MaxPermSize 可以换任意JVM参数 比如PermSize)
[xxxxxxxx ~]$ jinfo -flag MaxPermSize 12191
-XX:MaxPermSize=
[xxxxxxxx ~]$ jinfo -flag PermSize 12191
-XX:PermSize=
[admin@dw_web4 ~]$ jinfo -flag LargePageSizeInBytes 12191
-XX:LargePageSizeInBytes=
用main jinfo查看更多使用方法介绍
======================================
JSTAT(我最喜欢用的) 另外还有一个jvmstat 可视化的,我这里不做介绍 有兴趣&&下载玩玩
监视VM的内存工具,可以用来监视vm内存内的各种堆和非堆的大小及其内存使用量,可以观察到classloader,compiler,gc 相关信息。(兴趣高起来了 等下我在提供一个&,上一篇博客关于&主要是介绍写并发程序)
jstat -gcutil:统计gc时,heap情况
[xxxxxxxx ~]$ jstat -gcutil
& S0&&&& S1&&&& E&&&&& O&&&&& P&&&& YGC&&&& YGCT&&& FGC&&& FGCT&&&& GCT&&
100.00&& 0.00& 70.12&& 2.33& 43.55&&&&& 4&&& 0.243&&&& 0&&& 0.000&&& 0.243
100.00&& 0.00& 70.12&& 2.33& 43.55&&&&& 4&&& 0.243&&&& 0&&& 0.000&&& 0.243
100.00&& 0.00& 70.79&& 2.33& 43.56&&&&& 4&&& 0.243&&&& 0&&& 0.000&&& 0.243
100.00&& 0.00& 75.15&& 2.33& 43.79&&&&& 4&&& 0.243&&&& 0&&& 0.000&&& 0.243
100.00&& 0.00& 75.15&& 2.33& 43.79&&&&& 4&&& 0.243&&&& 0&&& 0.000&&& 0.243
100.00&& 0.00& 81.15&& 2.33& 44.51&&&&& 4&&& 0.243&&&& 0&&& 0.000&&& 0.243
100.00&& 0.00& 83.15&& 2.33& 44.63&&&&& 4&&& 0.243&&&& 0&&& 0.000&&& 0.243
间隔250毫秒 打印7行
jstat -gccause 监控内存使用情况 参数 (查看内存溢出相对有用)
[xxxxxxxx ~]$ jstat -gccause
(每隔3秒监控一次)
& S0&&&& S1&&&& E&&&&& O&&&&& P&&&& YGC&&&& YGCT&&& FGC&&& FGCT&&&& GCT&&& LGCC&&&&&&&&&&&&&&&& GCC&&&&&&&&&&&&&&&&
100.00&& 0.00& 93.97&& 2.35& 44.71&&&&& 4&&& 0.259&&&& 0&&& 0.000&&& 0.259 unknown GCCause&&&&& No GC&&&&&&&&&&&&&&
100.00&& 0.00& 93.97&& 2.35& 44.72&&&&& 4&&& 0.259&&&& 0&&& 0.000&&& 0.259 unknown GCCause&&&&& No GC
下面copy一份介绍:
S0& Survivor space 0 utilization as a percentage of the space’s current capacity.
S1& Survivor space 1 utilization as a percentage of the space’s current capacity.
E& Eden space utilization as a percentage of the space’s current capacity.
O& Old space utilization as a percentage of the space’s current capacity.
P Permanent space utilization as a percentage of the space’s current capacity.
YGC Number of young generation GC events.
YGCT Young generation garbage collection time.
FGC& Number of full GC events.
FGCT Full garbage collection time.
GCT Total garbage collection time.
LGCC& Cause of last Garbage Collection.
GCC Cause of current Garbage Collection.
jstat -class pid:显示加载class的数量,及所占空间等信息。
[xxxxxxxx web-deploy]$ jstat -class 12191
Loaded& Bytes& Unloaded& Bytes&&&& Time&&
& .9&&&&&&& 0&&&& 0.0&&&&&& 1.68
jstat -compiler pid:显示VM实时编译的数量等信息。
[xxxxxxxx web-deploy]$ jstat -compiler 12191
Compiled Failed Invalid&& Time&& FailedType FailedMethod
&&& 1029&&&&& 0&&&&&& 0&&&& 9.42&&&&&&&&& 0
jstat -gc pid:可以显示gc的信息,查看gc的次数,及时间。其中最后五项,分别是young gc的次数,young gc的时间,full gc的次数,full gc的时间,gc的总时间。
[xxxxxxxx ~]$ jstat -gc 12191
&S0C&&& S1C&&& S0U&&& S1U&&&&& EC&&&&&& EU&&&&&&& OC&&&&&&&& OU&&&&&& PC&&&& PU&&& YGC&&&& YGCT&&& FGC&&& FGCT&&&& GCT&&
76.0& 0.0&& 792.0 35008.0&& 72266.8&&
60144.0&&&&& 5&&& 0.338&& 0&&&&& 0.000&&& 0.338
jstat -gccapacity:可以显示,VM内存中三代(包括新生区,老年区,permanent区)对象的使用和占用大小,如:PGCMN显示的是最小 perm的内存使用量,PGCMX显示的是perm的内存最大使用量,PGC是当前新生成的perm内存占用量,PC是但前perm内存占用量。其他的可以根据这个类推, OC是old内纯的占用量。
[xxxxxxxx ~]$ jstat -gccapacity 12191
&NGCMN&&& NGCMX&&&& NGC&&&& S0C&& S1C&&&&&& EC&&&&& OGCMN&&&&& OGCMX&&&&&& OGC&&&&&&&& OC&&&&& PGCMN&&& PGCMX&&&& PGC&&&&&& PC&&&& YGC&&& FGC
76.0 & & & &
&&&&& 5&&&& 0
jstat -gcnew pid:统计gc时,new新生代的情况
[xxxxxxxx ~]$ jstat -gcnew 12191
&S0C&&& S1C&&& S0U&&& S1U&& TT MTT& DSS&&&&& EC&&&&&& EU&&&& YGC&&&& YGCT&
76.0&&& 0.0 && 4 792.0& 76512.8&&&&& 5&&& 0.338
jstat -gcnewcapacity pid:new对象的信息及其占用量。
jstat -gcold pid:old对象的信息。
jstat -gcoldcapacity pid:old对象的信息及其占用量。
jstat -gcpermcapacity pid: perm对象的信息及其占用量。
jstat -printcompilation pid:当前VM执行的信息。除了以上一个参数外,还可以同时加上 两个数字,如:jstat -printcompilation 是每250毫秒打印一次,一共打印6次,还可以加上-h3每三行显示一下标题。
man jstat查看更详细的吧
=========================================
可以观察到jvm中当前所有线程的运行情况和线程当前状态
jstack pid 运行看看,内容很多只列出部分
[xxxxxxxx ~]$ jstack 12191
Full thread dump Java HotSpot(TM) 64-Bit Server VM (11.0-b16 mixed mode):
“Attach Listener” daemon prio=10 tid=0×a11c00 nid=0×4430 waiting on condition [0x0]
&& java.lang.Thread.State: RUNNABLE
“http-0.0.0.0-7001-2″ daemon prio=10 tid=0×b000 nid=0×2fe5 in Object.wait() [0xaf000..0xafc90]
&& java.lang.Thread.State: WAITING (on object monitor)
&&&&&&& at java.lang.Object.wait(Native Method)
&&&&&&& – waiting on &0×00002aaabc8700d8& (a org.apache.tomcat.util.net.MasterSlaveWorkerThread)
&&&&&&& at java.lang.Object.wait(Object.java:485)
&&&&&&& at org.apache.tomcat.util.net.MasterSlaveWorkerThread.await(MasterSlaveWorkerThread.java:81)
&&&&&&& – locked &0×00002aaabc8700d8& (a org.apache.tomcat.util.net.MasterSlaveWorkerThread)
&&&&&&& at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:107)
&&&&&&& at java.lang.Thread.run(Thread.java:619)
“http-0.0.0.0-7001-1″ daemon prio=10 tid=0×9c00 nid=0×2fe4 in Object.wait() [0xe000..0xec10]
&& java.lang.Thread.State: WAITING (on object monitor)
&&&&&&& at java.lang.Object.wait(Native Method)
&&&&&&& – waiting on &0×00002aaabcaef5d0& (a org.apache.tomcat.util.net.MasterSlaveWorkerThread)
&&&&&&& at java.lang.Object.wait(Object.java:485)
&&&&&&& at org.apache.tomcat.util.net.MasterSlaveWorkerThread.await(MasterSlaveWorkerThread.java:81)
&&&&&&& – locked &0×00002aaabcaef5d0& (a org.apache.tomcat.util.net.MasterSlaveWorkerThread)
&&&&&&& at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:107)
&&&&&&& at java.lang.Thread.run(Thread.java:619)
“TP-Monitor” daemon prio=10 tid=0×00002aab406b0000 nid=0×2fe3 in Object.wait() [0xd000..0xdb90]
&& java.lang.Thread.State: TIMED_WAITING (on object monitor)
&&&&&&& at java.lang.Object.wait(Native Method)
&&&&&&& at org.apache.tomcat.util.threads.ThreadPool$MonitorRunnable.run(ThreadPool.java:559)
&&&&&&& – locked &0×00002aaabcd6ea98& (a org.apache.tomcat.util.threads.ThreadPool$MonitorRunnable)
&&&&&&& at java.lang.Thread.run(Thread.java:619)
“TP-Processor4″ daemon prio=10 tid=0×00002aab414f0800 nid=0×2fe2 runnable [0xec000..0xecb10]
&& java.lang.Thread.State: RUNNABLE
&&&&&&& at java.net.PlainSocketImpl.socketAccept(Native Method)
&&&&&&& at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
&&&&&&& – locked &0×00002aaabcfedfd8& (a java.net.SocksSocketImpl)
&&&&&&& at java.net.ServerSocket.implAccept(ServerSocket.java:453)
&&&&&&& at java.net.ServerSocket.accept(ServerSocket.java:421)
&&&&&&& at org.mon.ChannelSocket.accept(ChannelSocket.java:306)
&&&&&&& at org.mon.ChannelSocket.acceptConnections(ChannelSocket.java:660)
&&&&&&& at org.mon.ChannelSocket$SocketAcceptor.runIt(ChannelSocket.java:870)
&&&&&&& at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
&&&&&&& at java.lang.Thread.run(Thread.java:619)
………………………………………….
……………………………………………
等等。。。
==============================================
打印出某个java进程内存内所有对象的情况(产生的对象以及数量)
jmap -histo pid 打印jvm heap的直方图。其输出信息包括类名,对象数量,对象占用大小。 内容会比较多 不方便查看可以将其保存到文本中去。(jmap -histo pid&histo.log)
该命令检查内存泄漏 是很有用哦。
[xxxxxxxx ~]$ more histo.log
&num&&&& #instances&&&&&&&& #bytes& class name
———————————————-
&& 1:&&&&&&& 251510&&&&&& & [C
&& 2:&&&&&&&& 53304&&&&&& & [I
&& 3:&&&&&&&& 90608&&&&&& & &constMethodKlass&
&& 4:&&&&&&&& 90608&&&&&& & &methodKlass&
&& 5:&&&&&&& 256090&&&&&& & java.lang.String
&& 6:&&&&&&&&& 8209&&&&&&& 9233040& &constantPoolKlass&
&& 7:&&&&&&&& 74133&&&&&&& 9109848& [B
&& 8:&&&&&&& 129787&&&&&&& 6779512& &symbolKlass&
&& 9:&&&&&&&&& 8209&&&&&&& 6552912& &instanceKlassKlass&
& 10:&&&&&&& 111943&&&&&&& 6268808& java.util.HashMap$ValueIterator
& 11:&&&&&&&& 94562&&&&&&& 6051968& java.util.TreeMap$Entry
& 12:&&&&&&&&& 7083&&&&&&& 5493440& &constantPoolCacheKlass&
& 13:&&&&&&& 109800&&&&&&& 5270400& org.apache.catalina.LifecycleEvent
& 14:&&&&&&&& 28087&&&&&&& 5116800& [Ljava.lang.O
& 15:&&&&&&&& 34532&&&&&&& 4681168& [Ljava.util.HashMap$E
& 16:&&&&&&&& 27458&&&&&&& 4173616& java.lang.reflect.Method
& 17:&&&&&&& 109800&&&&&&& 3498960& [Lorg.apache.catalina.C
& 18:&&&&&&&& 66949&&&&&&& 3213552& java.util.HashMap$Entry
& 19:&&&&&&& 109970&&&&&&& 2771112& [Lorg.apache.catalina.LifecycleL
& 20:&&&&&&&& 32831&&&&&&& 2101184& java.util.HashMap
& 21:&&&&&&&& 34327&&&&&&& 1828320& [Ljava.lang.S
& 22:&&&&&&&& 21356&&&&&&& 1708480& java.util.TreeMap
& 23:&&&&&&&&& 8785&&&&&&& 1616440& java.lang.Class
..................
..................
..................
jmap -dump:format=b,file=heap.log&&12191可以将&12191进程的内存heap输出出来到heap.log 文件里。
jmap -heap pid(该命令我用的比较多) 打印出heap情况,可以观察到New Generation(Eden Space,From Space,To Space),tenured generation,Perm Generation的内存使用情况。
[xxxxxxxx ~]$ jmap -heap 12191&
Attaching to process ID 12191, please wait…
Debugger attached successfully.
Server compiler detected.
JVM version is 11.0-b16
using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GC
Heap Configuration:
&& MinHeapFreeRatio = 40
&& MaxHeapFreeRatio = 70
&& MaxHeapSize&&&&& =
(2048.0MB)
&& NewSize&&&&&&&&& =
&& MaxNewSize&&&&&& =
&& OldSize&&&&&&&&& =
&& NewRatio&&&&&&&& = 7
&& SurvivorRatio&&& = 8
&& PermSize&&&&&&&& =
&& MaxPermSize&&&&& =
Heap Usage:
New Generation (Eden + 1 Survivor Space):
&& capacity =
(230.4375MB)
&& used&&&& = .53MB)
&& free&&&& =
(140.47MB)
&& 39.96% used
Eden Space:
&& capacity =
(204.875MB)
&& used&&&& = .53MB)
&& free&&&& =
(140.47MB)
&& 31.035% used
From Space:
&& capacity = .5625MB)
&& used&&&& = .5625MB)
&& free&&&& = 0 (0.0MB)
&& 100.0% used
&& capacity = .5625MB)
&& used&&&& = 0 (0.0MB)
&& free&&&& = .5625MB)
&& 0.0% used
concurrent mark-sweep generation:
&& capacity =
(1792.0MB)
&& used&&&& = .72MB)
&& free&&&& =
(473633MB)
&& 3.4597% used
Perm Generation:
&& capacity =
&& used&&&& = .5MB)
&& free&&&& = .5MB)
&& 45.516% used
jmap -permstat pid 打印permanent generation heap情况
更多信息查看man jmap
&& OPTIONS&
&&&&&&&&& &no option&&
&&&&&&&&&&&& When& no& option& is used jmap prints shared object mappings. For each shared object loaded in the target&
&&&&&&&&&&&& VM, start address, the size of the mapping, and the full path of the shared object file are printed. This&
&&&&&&&&&&&& is similar to the Solaris pmap utility.
&&&&&&&&& -dump:[live,]format=b,file=&filename&&
&&&&&&&&&&&& Dumps& the& Java& heap& in hprof binary format to filename. The live suboption is optional. If specified,&
&&&&&&&&&&&& only the live objects in the heap are dumped. To browse the heap dump, you can& use& jhat(1)& (Java& Heap&
&&&&&&&&&&&& Analysis Tool) to read the generated file.
&&&&&&&&& -finalizerinfo&
&&&&&&&&&&&& Prints information on objects awaiting finalization.
&&&&&&&&& -heap&
&&&&&&&&&&&& Prints& a heap summary. GC algorithm used, heap configuration and generation wise heap usage are printed.
&&&&&&&&& -histo[:live]&
&&&&&&&&&&&& Prints a histogram of the heap. For each Java class, number of objects, memory size in bytes,& and& fully&
&&&&&&&&&&&& qualified& class names are printed. VM internal class names are printed with ‘*’ prefix. If the live sub-&
&&&&&&&&&&&& option is specified, only live objects are counted.
&&&&&&&&& -permstat&
&&&&&&&&&&&& Prints class loader wise statistics of permanent generation of Java heap.& For& each& class& loader,& its&
&&&&&&&&&&&& name,& liveness,& address,& parent& class& loader,& and& the number and size of classes it has loaded are&
&&&&&&&&&&&& printed. In addition, the number and size of interned Strings are printed.
&&&&&&&&& -F Force. Use with jmap -dump or jmap -histo option if the pid does not respond. The live suboption& is& not&
&&&&&&&&&&&& supported in this mode.
&&&&&&&&& -h Prints a help message.
&&&&&&&&& -help&
&&&&&&&&&&&& Prints a help message.
&&&&&&&&& -J&flag&&
&&&&&&&&&&&& Passes &flag& to the Java virtual machine on which jmap is run.
=============================================
一个java GUI监视工具,可以以图表化的形式显示各种数据,并可通过远程连接监视远程的服务器VM。
个人喜欢稍微简单易用jstat来查看。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:204756次
积分:4407
积分:4407
排名:第5237名
原创:154篇
转载:548篇
评论:13条
细节决定成败,
态度决定一切。
文章:32篇
阅读:8882
(1)(1)(3)(6)(2)(24)(32)(31)(1)(6)(108)(7)(25)(232)(65)(12)(2)(2)(6)(2)(4)(21)(120)mac下装MyEclipse需要虚拟内存 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
已注册用户请 &
Sponsored by
国内领先的实时通信云为开发者和企业提供安全可靠的场景化实时通信云服务
Promoted by
mac下装MyEclipse需要虚拟内存
18:52:13 +08:00 · 4576 次点击
mac没有这种swap分区 怎么办
我记得linux下用dd和mount 可以造一个
6 回复 &| &直到
12:30:10 +08:00
& & 20:24:11 +08:00 via iPad
OSX 本来就有的吧 不需要独立分区
& & 20:49:55 +08:00
没有交換分區, 但虛擬内存是有的.
/private/var/vm/swapfile* 就是虛擬内存. 默認狀態下是開啟的, 如果關上了可以用
sudo launchctl load -w System/Library/LaunchDaemons/com.apple.metadata.mds.plist
重新開啟.
& & 21:19:30 +08:00
我知道但是那个安装程序检测有没有swap分区
& & 21:23:47 +08:00
哪个版本啊?我myeclipse9 装的时候一切正常
& & 21:25:29 +08:00
好吧追新不好
& & 12:30:10 +08:00
楼主解决了没有啊....急求答案...分享给我这可怜人吧..
& · & 625 人在线 & 最高记录 2399 & · &
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.7.5 · 51ms · UTC 17:19 · PVG 01:19 · LAX 09:19 · JFK 12:19? Do have faith in what you're doing.

我要回帖

更多关于 hyperv虚拟机监控程序 的文章

 

随机推荐