tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Einfeldt <ralph.einfe...@uptime-isc.de>
Subject AW: Monitor memory and CPU usage of servlets from inside of Tomca t
Date Thu, 15 Feb 2001 10:15:19 GMT
One easy way to achieve the memory part:

We use our own logging and have build in something like
the following in the log method:

// snip
    boolean oWatchMemory = false;
    Runtime oRuntime = Runtime.getRuntime();
    int oGCCount = 0;
    int oGCInterval = 100;
// snip
void log(....) {
  if (oWatchMemory) {
    if ((oGCInterval > 0) && (oGCCount >= oGCInterval)) {
      mBuffer.append("gc#");
      System.gc();
      oGCCount = 0;
    }
    oGCCount++;
    mBuffer.append("used#" + 
                            (oRuntime.totalMemory() - 
                             oRuntime.freeMemory()) +
                             "total#" + oRuntime.totalMemory() +
                             "#free#" + oRuntime.freeMemory()+ "#");
// snip
  }
// snip
}	

It's nothing compared against a good memory profiler, 
but is cheap and easy to use.

I don't know any free profilers for java. (Haven't searched much)

> -----Ursprungliche Nachricht-----
> Von: Emil Genov [mailto:egenov@simplesoft.bg]
> Gesendet: Donnerstag, 15. Februar 2001 11:43
> An: tomcat-user@jakarta.apache.org; egenov@simplsoft.bg
> Betreff: Monitor memory and CPU usage of servlets from inside 
> of Tomcat
<snip/>
> I need to monitor memory usage
<snap/>

Mime
View raw message