Skip to content

Commit 0da2779

Browse files
committed
Change return type to int
1 parent f65f5e5 commit 0da2779

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

arthas-vmtool/src/main/java/arthas/VmTool.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ public Class<?>[] getAllLoadedClasses() {
117117
}
118118

119119
@Override
120-
public boolean mallocTrim() {
120+
public int mallocTrim() {
121121
return mallocTrim0();
122122
}
123123

124-
private static synchronized native boolean mallocTrim0();
124+
private static synchronized native int mallocTrim0();
125125
}

arthas-vmtool/src/main/java/arthas/VmToolMXBean.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ public interface VmToolMXBean {
6161
/**
6262
* glibc 释放空闲内存
6363
*/
64-
public boolean mallocTrim();
64+
public int mallocTrim();
6565
}

arthas-vmtool/src/main/native/src/jni-library.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,10 @@ JNIEXPORT jobjectArray JNICALL Java_arthas_VmTool_getAllLoadedClasses0
210210
}
211211

212212
extern "C"
213-
JNIEXPORT jboolean JNICALL Java_arthas_VmTool_mallocTrim0
213+
JNIEXPORT jint JNICALL Java_arthas_VmTool_mallocTrim0
214214
(JNIEnv *env, jclass thisClass) {
215215
#ifdef __GLIBC__
216-
if (!::malloc_trim(0)) {
217-
return JNI_FALSE;
218-
}
216+
return ::malloc_trim(0);
219217
#endif
220-
return JNI_TRUE;
218+
return -1;
221219
}

core/src/main/java/com/taobao/arthas/core/command/monitor200/VmToolCommand.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,10 @@ public void process(final CommandProcess process) {
241241

242242
return;
243243
} else if (VmToolAction.mallocTrim.equals(action)) {
244-
boolean result = vmToolInstance().mallocTrim();
244+
int result = vmToolInstance().mallocTrim();
245245
process.write("\n");
246-
process.end(result ? 0 : -1, "mallocTrim result: " + result);
246+
process.end(result == 1 ? 0 : -1, "mallocTrim result: " +
247+
(result == 1 ? "true" : (result == 0 ? "false" : "not supported")));
247248
return;
248249
}
249250

0 commit comments

Comments
 (0)