Hi all,
I'm just getting started with webapp performance testing with JMeter,
and I noticed the bug mentioned in the thread 'Possible bug in monitor
results listener' from late last year, still present in release 2.0.3
.  I downloaded the nightly 2-1.20050812, only to find that the bug
"fix" in CVS is still a little off.  The memory usage that most people
want to see (IMHO) is:

current usage / maximum available

as opposed to:

current usage / current heap size


They don't really care what the JVM is doing to the current heap size;
they just want to know the absolute usage, and how close the are to an
OutOfMemoryError.  Additionally, since the *currently allocated* heap
size will change whenever the JVM decides to change it, using it for
the denominator makes it very hard to get an idea of the actual usage.
 I'm much too lazy to submit an actual patch, but in
$JMETER_HOME/src/monitor/components/org/apache/jmeter/monitor/util/Stats.java
, I changed the two methods below, and the results make a whole lot
more sense this way.

       public static int calculateMemoryLoad(Status stat) {
               double load = 0;
               if (stat != null) {
                       long total = stat.getJvm().getMemory().getTotal();
                       long free = stat.getJvm().getMemory().getFree();
                       long used = total - free;
                       long max = stat.getJvm().getMemory().getMax();
                       load = ((double)used / (double)max);
               }
               return (int) (load * 100);
       }

       public static int calculateLoad(Status stat) {
               if (stat != null) {
                       long total = stat.getJvm().getMemory().getTotal();
                       long free = stat.getJvm().getMemory().getFree();
                       long used = total - free;
                       long max = stat.getJvm().getMemory().getMax();
                       double memdiv = ((double)used / (double)max);
                       double memWeight = DEFAULT_MEMORY_FACTOR * memdiv;

                       // changed the logic for BEA Weblogic in the case a
                       // user uses Tomcat's status servlet without any
                       // modifications. Weblogic will return nothing for
                       // the connector, therefore we need to check the size
                       // of the list. Peter 12.22.04
                       double threadWeight = 0;
                       if (stat.getConnector().size() > 0) {
                               Connector cntr = (Connector)
stat.getConnector().get(0);
                               int maxThread =
cntr.getThreadInfo().getMaxThreads();
                               int curThread =
cntr.getThreadInfo().getCurrentThreadsBusy();
                               double thdiv = (double) curThread /
(double) maxThread;
                               threadWeight = DEFAULT_THREAD_FACTOR * thdiv;
                       }
                       return (int) (memWeight + threadWeight);
               } else {
                       return 0;
               }
       }

-Jon

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to