Use the actual available free memory instead of the max possible

This commit is contained in:
Laurent Clouet
2018-08-10 17:33:50 +02:00
parent 4dc0603587
commit 6ded57fc0a
6 changed files with 65 additions and 1 deletions

View File

@@ -102,6 +102,21 @@ public class Windows extends OS {
return 0;
}
@Override
public int getFreeMemory() {
try {
MEMORYSTATUSEX _memory = new MEMORYSTATUSEX();
if (Kernel32.INSTANCE.GlobalMemoryStatusEx(_memory)) {
return (int) (_memory.ullAvailPhys.longValue() / 1024); // size in KB
}
}
catch (Exception e) {
e.printStackTrace();
}
return -1;
}
@Override
public String getCUDALib() {
return "nvcuda";