mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
kvm available memory calculation optimization (#5540)
* Update LibvirtComputingResource.java * Update LibvirtComputingResource.java * Update LibvirtComputingResource.java re * Update MemStat.java * Update MemStat.java * Update MemStatTest.java
This commit is contained in:
parent
cd4e7e031a
commit
52a9dbdcd2
@ -35,6 +35,7 @@ public class MemStat {
|
||||
protected final static String FREE_KEY = "MemFree";
|
||||
protected final static String CACHE_KEY = "Cached";
|
||||
protected final static String TOTAL_KEY = "MemTotal";
|
||||
protected final static String BUFFER_KEY = "Buffers";
|
||||
long reservedMemory;
|
||||
long overCommitMemory;
|
||||
|
||||
@ -55,7 +56,7 @@ public class MemStat {
|
||||
}
|
||||
|
||||
public long getAvailable() {
|
||||
return getFree() + getCache();
|
||||
return getFree() + getCache() + getBuffer();
|
||||
}
|
||||
|
||||
public long getFree() {
|
||||
@ -66,6 +67,10 @@ public class MemStat {
|
||||
return _memStats.get(CACHE_KEY);
|
||||
}
|
||||
|
||||
public long getBuffer() {
|
||||
return _memStats.get(BUFFER_KEY);
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
File f = new File(MEMINFO_FILE);
|
||||
try (Scanner scanner = new Scanner(f,"UTF-8")) {
|
||||
|
||||
@ -48,7 +48,7 @@ public class MemStatTest {
|
||||
MemStat memStat = new MemStat();
|
||||
|
||||
Assert.assertEquals(memStat.getTotal(), 5970161664L);
|
||||
Assert.assertEquals(memStat.getAvailable(), 2829840384L);
|
||||
Assert.assertEquals(memStat.getAvailable(), 3164520448L);
|
||||
Assert.assertEquals(memStat.getFree(), 160514048L);
|
||||
Assert.assertEquals(memStat.getCache(), 2669326336L);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user