如何防止Java创建hsperfdata文件?

时间:2020-03-05 18:57:01  来源:igfitidea点击:

我正在编写一个在Linux上运行的Java应用程序(使用Sun的JDK)。我一直在阻止创建/ tmp / hsperfdata_username目录。有什么方法可以阻止Java创建这些文件?

解决方案

回答

编辑:清理信息和摘要

概括:

  • 它是功能,不是错误
  • 可以使用-XX:-UsePerfData将其关闭,这可能会影响性能

相关信息:

  • 太阳论坛
  • 错误报告

回答

尝试JVM选项-XX:-UsePerfData

更多信息

来自链接https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html的以下内容可能会有所帮助

-XX:+UsePerfData

    Enables the perfdata feature. This option is enabled by default
    to allow JVM monitoring and performance testing. Disabling it 
    suppresses the creation of the hsperfdata_userid directories. 
    To disable the perfdata feature, specify -XX:-UsePerfData.

回答

从svrist的链接:

The first item in http://java.sun.com/performance/jvmstat/faq.html mentions an option which you can turn off to disable the whole suite of features: -XX:-UsePerfData.

回答

根据已提交的错误报告,有一个解决方法:

This undocumented option will disable
  the perfdata feature:

  -XX:-UsePerfData

值得一提的是,它是一个功能,而不是错误。上述解决方法只是禁用了该功能。

回答

还有一个" -XX:+ PerfDisableSharedMem"选项(Sun推荐),它引起的性能问题比使用" -XX:-UsePerfData"选项要少。

回答

使用JVM选项-XX:-UsePerfData

正如其他一些答案所言,这不会对性能产生负面影响。

默认情况下,HotSpot JVM中的jvmstat工具处于打开状态。 JVM选项-XX:-UsePerfData将其关闭。我推测,如果有的话,关闭仪器可以提高性能(微不足道)。

因此,关闭jvmstat工具的缺点是我们会丢失性能监视信息。

此处介绍了jvmstat,网址为http://java.sun.com/performance/jvmstat/

这是一个担心某个人的线程,担心它通过使用选项-XX:+ UsePerfData打开jvmstat会影响性能。
http://www.theserverside.com/discussions/thread.tss?thread_id=33833
(由于jvmstat被设计为"始终在线",而对性能的影响可忽略不计,因此可能不会。)