3 Replies Latest reply on Jun 5, 2013 5:10 PM by jtahlborn

    Script to get JVM Usage

      I am able to get System memory usage using Runtime class but I need to know how to get memory usage for specific java process on the server
      and mail to be sent. Appreciate if anybody help on this.
      System.out.println("Total Memory:" + runtime.totalMemory());
      System.out.println("Max Memory:" + runtime.maxMemory());
        • 1. Re: Script to get JVM Usage
          You can get a snapshot of the runtime's memory state yes. But to get the usage of a specific process is something you'd ask the operating system, this question has little to nothing to do with Java.
          1 person found this helpful
          • 2. Re: Script to get JVM Usage
            But still can't we grab the JVM usage using Java.
            • 3. Re: Script to get JVM Usage
              Maybe i'm not understanding your question, but if you are looking for how much memory the java process is using, you have the answer already (those lines of code in your original question). Those values are not the system memory size and usage, they are the jvm process memory allowance and usage.

              if you want the system values, you can use this JMX mbean: