How can I prevent Java from creating hsperfdata files?

Viewed 76136

I'm writing a Java application that runs on Linux (using Sun's JDK). It keeps creating /tmp/hsperfdata_username directories, which I would like to prevent. Is there any way to stop java from creating these files?

8 Answers

Try JVM option -XX:-UsePerfData

more info

The following might be helpful that is from link 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.

As an addendum to Mack's reply (answered Mar 25 '11 at 17:12), the option java.tmp.dir looks no longer available since Java 8. See the info at: https://bugs.java.com/view_bug.do?bug_id=8189674

So disabling the option using -XX:-UsePerfData seems the only option not to have hsperfdata_* files.

EDIT: Cleanup info and summarize

Summary:

  • Its a feature, not a bug
  • It can be turned of with -XX:-UsePerfData which might hurt performance

Relevant info:

According to the filed bug report there is a work-around:

This undocumented option will disable the perfdata feature:
-XX:-UsePerfData

It's worth mentioning that it is a feature though, not a bug. The above work-around just disables the feature.

Related