diff --git a/vjtop/pom.xml b/vjtop/pom.xml
index f2906069..1fdf0aa5 100644
--- a/vjtop/pom.xml
+++ b/vjtop/pom.xml
@@ -4,7 +4,7 @@
com.vip.vjtools
vjtop
- 1.0.4-SNAPSHOT
+ 1.0.4
vjtop
Linux top-like JVM info and busy threads monitoring tools
diff --git a/vjtop/src/main/java/com/vip/vjtools/vjtop/VMDetailView.java b/vjtop/src/main/java/com/vip/vjtools/vjtop/VMDetailView.java
index 30f925e8..3127e073 100755
--- a/vjtop/src/main/java/com/vip/vjtools/vjtop/VMDetailView.java
+++ b/vjtop/src/main/java/com/vip/vjtools/vjtop/VMDetailView.java
@@ -382,8 +382,10 @@ private void printTopMemoryThreads(DetailMode mode) throws IOException {
continue;
}
+ Long threadDelta = threadMemoryDeltaBytesMap.get(tid);
+ long allocationRate = threadDelta == null ? 0 : (threadDelta * 1000) / vmInfo.upTimeMills.delta;
System.out.printf(dataFormat, tid, threadName, Utils.leftStr(info.getThreadState().toString(), 10),
- Utils.toFixLengthSizeUnit((threadMemoryDeltaBytesMap.get(tid) * 1000) / vmInfo.upTimeMills.delta),
+ Utils.toFixLengthSizeUnit(allocationRate),
getThreadMemoryUtilization(threadMemoryDeltaBytesMap.get(tid), totalDeltaBytes),
Utils.toFixLengthSizeUnit(threadMemoryTotalBytesMap.get(tid)),
getThreadMemoryUtilization(threadMemoryTotalBytesMap.get(tid), totalBytes));
@@ -481,12 +483,10 @@ public void cleanupThreadsHistory() {
}
private static double getThreadMemoryUtilization(Long threadBytes, long totalBytes) {
- if (threadBytes == null) {
- return 0;
- }
- if (totalBytes == 0) {
+ if (threadBytes == null || totalBytes == 0) {
return 0;
}
+
return (threadBytes * 100d) / totalBytes;// 这里因为最后单位是百分比%,所以bytes除以totalBytes以后要乘以100,才可以再加上单位%
}