java jinfo命令(Java Configuration Info)

 jinfo可以输出并修改运行时的java 进程的opts。用处比较简单,用于输出JAVA系统参数及命令行参数。用法是jinfo -opt  pid 如:查看2788MaxPerm大小可以用  jinfo -flag MaxPermSize 2788

在JVM提供地几百个参数中,jinfo可以动态修改其中地很多参数,但是很多参数也是无法修改地。例如一些内存尺寸的参数是无法修改的(但可以通过jinfo查看这些参数值)。

许多关于“是否启用”类的参数是可以修改的,比如“-XX:+参数”和“-XX:-参数”。设置后就立即生效了。

一般来讲,对于运行时信息只能看,不能改,启动参数只有那么几个,很多参数是被启动参数引导出来的参数。只有在某些参数未设置的情况下,但又需要临时加上时可能会被用到(例如排查问题)。


用法:

# jinfo -h  
Usage:  
    jinfo [option] <pid>  
        (to connect to running process)  
    jinfo [option] <executable <core>  
        (to connect to a core file)  
    jinfo [option] [server_id@]<remote server IP or hostname>  
        (to connect to remote debug server)  
  
where <option> is one of:  
    -flag <name>         to print the value of the named VM flag  
    -flag [+|-]<name>    to enable or disable the named VM flag  
    -flag <name>=<value> to set the named VM flag to the given value  
    -flags               to print VM flags  
    -sysprops            to print Java system properties  
    <no option>          to print both of the above  
    -h | -help           to print this help message  

 例子:

$ jinfo -flag HeapDumpBeforeFullGC  29167  #查看HeapDumpBeforeFullGC  
-XX:-HeapDumpBeforeFullGC  
$ jinfo -flag +HeapDumpBeforeFullGC  29167  #打开HeapDumpBeforeFullGC  
$ jinfo -flag HeapDumpBeforeFullGC  29167  
-XX:+HeapDumpBeforeFullGC  
$ jinfo -flag -HeapDumpBeforeFullGC  29167  #关闭HeapDumpBeforeFullGC  
$ jinfo -flag HeapDumpBeforeFullGC  29167  
-XX:-HeapDumpBeforeFullGC  

 如果出现:

pid: well-known file is not secure  

 请确认当前执行jinfo的命令的用户有/tmp/hsperfdata_$USER/$PID 文件的权限

 如果出现:

Exception in thread "main" java.io.IOException: Command failed in target VM  
        at sun.tools.attach.LinuxVirtualMachine.execute(LinuxVirtualMachine.java:218)  
        at sun.tools.attach.HotSpotVirtualMachine.executeCommand(HotSpotVirtualMachine.java:213)  
        at sun.tools.attach.HotSpotVirtualMachine.setFlag(HotSpotVirtualMachine.java:190)  
        at sun.tools.jinfo.JInfo.flag(JInfo.java:123)  
        at sun.tools.jinfo.JInfo.main(JInfo.java:76) 

 说明参数不支持修改

 另外,jinfo可能在未来的jvm中移除。

 

 参考资料:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4109888

http://blog.tsunanet.net/2010/10/ioexception-well-known-file-is-not.html

http://docs.oracle.com/javase/6/docs/technotes/tools/share/jinfo.html


转载自:http://softbeta.iteye.com/blog/1498111

参考:http://blog.csdn.net/fenglibing/article/details/6411958

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值