tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Dale <jcdw...@gmail.com>
Subject Re: How to display the current In-Use Stack Size
Date Mon, 04 Mar 2019 20:10:53 GMT
Something like this maybe?

String[] cmd = {
"/bin/sh",
"-c",
"ps -eo rss,comm --sort rss"
};

            Process p = Runtime.getRuntime().exec(cmd);

  p.waitFor();
  BufferedReader buf = new BufferedReader(new InputStreamReader(
          p.getInputStream()));
  String line = "";
  String output = "";

  while ((line = buf.readLine()) != null)
  {
    if(line.indexOf("java") > 0)
    {
        output += line + "\n";
    }
  }

  out.println(output);
System.out.println(output);

On 3/4/19, Campbell, Lance <lance@illinois.edu> wrote:
> I have seen those as well.  I was hoping someone knew if there was a way to
> view the Java Stack in particular.
>
> ´╗┐On 3/4/19, 11:16 AM, "John Dale" <jcdwrrc@gmail.com> wrote:
>
>     I found this in some old code .. not sure if it works.  Let me know.
>
>     //Getting the runtime reference from system
>                 Runtime runtime = Runtime.getRuntime();
>
>                 //Print used memory
>                 out.println("Used Memory: "
>                     + ((runtime.totalMemory() - runtime.freeMemory()) / mb)
> + "MB");
>                 out.println("<br/>");
>
>                 //Print free memory
>                 out.println("Free Memory: "
>                     + (runtime.freeMemory() / mb) + "MB");
>                 out.println("<br/>");
>
>                 //Print total available memory
>                 out.println("Total Memory: " + (runtime.totalMemory() / mb)
> + "MB");
>                 out.println("<br/>");
>
>                 //Print Maximum available memory
>                 out.println("Max Memory: " + (runtime.maxMemory() / mb) +
> "MB");
>                 out.println("<br/>");
>
>     On 3/4/19, Campbell, Lance <lance@illinois.edu> wrote:
>     > Tomcat 9.x
>     > What is the easiest way to identify how much memory Tomcat/Java is
> currently
>     > using from the Java stack -Xss ?  Not max but currently being used.
>     >
>     > Is there a particular statement I can put into a servlet to see what
> the
>     > current memory usage is of the stack?
>     >
>     > Thanks,
>     >
>     > Lance
>     >
>
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>     For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message