Memory amount should be in long not int

This commit is contained in:
Laurent Clouet
2019-02-20 13:46:53 +01:00
parent 6d9ca8ef2c
commit 208f49ba1d
10 changed files with 25 additions and 25 deletions

View File

@@ -111,7 +111,7 @@ public class FreeBSD extends OS {
}
@Override
public int getMemory() {
public long getMemory() {
try {
Runtime r = Runtime.getRuntime();
Process p = r.exec("sysctl -n hw.usermem");
@@ -124,7 +124,7 @@ public class FreeBSD extends OS {
return 0;
}
Long mem_byte = Long.parseLong(line.trim());
return (int) (mem_byte / Long.valueOf(1024));
return mem_byte / Long.valueOf(1024);
}
catch (IOException e) {
Log.getInstance(null).debug("OS::FreeBSD::getMemory exception " + e);
@@ -134,7 +134,7 @@ public class FreeBSD extends OS {
}
@Override
public int getFreeMemory() {
public long getFreeMemory() {
return -1;
}

View File

@@ -88,7 +88,7 @@ public class Linux extends OS {
}
@Override
public int getMemory() {
public long getMemory() {
try {
String filePath = "/proc/meminfo";
Scanner scanner = new Scanner(new File(filePath));
@@ -117,7 +117,7 @@ public class Linux extends OS {
}
@Override
public int getFreeMemory() {
public long getFreeMemory() {
try {
String filePath = "/proc/meminfo";
Scanner scanner = new Scanner(new File(filePath));

View File

@@ -98,7 +98,7 @@ public class Mac extends OS {
}
@Override
public int getMemory() {
public long getMemory() {
String command = "sysctl hw.memsize";
Process p = null;
@@ -113,7 +113,7 @@ public class Mac extends OS {
if (line.startsWith(option)) {
String memory = line.substring(option.length()).trim(); // memory in bytes
return (int) (Long.parseLong(memory) / 1024);
return Long.parseLong(memory) / 1024;
}
}
input.close();
@@ -141,7 +141,7 @@ public class Mac extends OS {
}
@Override
public int getFreeMemory() {
public long getFreeMemory() {
return -1;
}

View File

@@ -31,9 +31,9 @@ public abstract class OS {
public abstract CPU getCPU();
public abstract int getMemory();
public abstract long getMemory();
public abstract int getFreeMemory();
public abstract long getFreeMemory();
public abstract String getRenderBinaryPath();

View File

@@ -89,11 +89,11 @@ public class Windows extends OS {
}
@Override
public int getMemory() {
public long getMemory() {
try {
MEMORYSTATUSEX _memory = new MEMORYSTATUSEX();
if (Kernel32.INSTANCE.GlobalMemoryStatusEx(_memory)) {
return (int) (_memory.ullTotalPhys.longValue() / 1024); // size in KB
return _memory.ullTotalPhys.longValue() / 1024; // size in KB
}
}
catch (Exception e) {
@@ -103,11 +103,11 @@ public class Windows extends OS {
}
@Override
public int getFreeMemory() {
public long getFreeMemory() {
try {
MEMORYSTATUSEX _memory = new MEMORYSTATUSEX();
if (Kernel32.INSTANCE.GlobalMemoryStatusEx(_memory)) {
return (int) (_memory.ullAvailPhys.longValue() / 1024); // size in KB
return _memory.ullAvailPhys.longValue() / 1024; // size in KB
}
}
catch (Exception e) {