Memory amount should be in long not int
This commit is contained in:
@@ -50,7 +50,7 @@ public class Configuration {
|
||||
private String proxy;
|
||||
private int maxUploadingJob;
|
||||
private int nbCores;
|
||||
private int maxMemory; // max memory allowed for render
|
||||
private long maxMemory; // max memory allowed for render
|
||||
private int maxRenderTime; // max render time per frame allowed
|
||||
private int priority;
|
||||
private ComputeType computeMethod;
|
||||
@@ -152,11 +152,11 @@ public class Configuration {
|
||||
return this.nbCores;
|
||||
}
|
||||
|
||||
public void setMaxMemory(int max) {
|
||||
public void setMaxMemory(long max) {
|
||||
this.maxMemory = max;
|
||||
}
|
||||
|
||||
public int getMaxMemory() {
|
||||
public long getMaxMemory() {
|
||||
return this.maxMemory;
|
||||
}
|
||||
|
||||
|
||||
@@ -290,8 +290,8 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
|
||||
HttpURLConnection connection = null;
|
||||
try {
|
||||
OS os = OS.getOS();
|
||||
int maxMemory = this.user_config.getMaxMemory();
|
||||
int freeMemory = os.getFreeMemory();
|
||||
long maxMemory = this.user_config.getMaxMemory();
|
||||
long freeMemory = os.getFreeMemory();
|
||||
if (maxMemory < 0) {
|
||||
maxMemory = freeMemory;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class SettingsLoader {
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsLoader(String path_, String login_, String password_, String proxy_, String hostname_, ComputeType computeMethod_, GPUDevice gpu_, int cores_, int maxRam_, int maxRenderTime_, String cacheDir_, boolean autoSignIn_, String ui_, String tileSize_, int priority_) {
|
||||
public SettingsLoader(String path_, String login_, String password_, String proxy_, String hostname_, ComputeType computeMethod_, GPUDevice gpu_, int cores_, long maxRam_, int maxRenderTime_, String cacheDir_, boolean autoSignIn_, String ui_, String tileSize_, int priority_) {
|
||||
if (path_ == null) {
|
||||
path = getDefaultFilePath();
|
||||
}
|
||||
@@ -350,7 +350,7 @@ public class SettingsLoader {
|
||||
}
|
||||
|
||||
if (config.getMaxMemory() == -1 && ram != null) {
|
||||
config.setMaxMemory(Integer.valueOf(ram));
|
||||
config.setMaxMemory(Long.valueOf(ram));
|
||||
}
|
||||
|
||||
if (config.getMaxRenderTime() == -1 && renderTime != null) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -73,7 +73,7 @@ public class Worker {
|
||||
private int nb_cores = -1;
|
||||
|
||||
@Option(name = "-memory", usage = "Maximum memory allow to be used by renderer (in MB)", required = false)
|
||||
private int max_ram = -1;
|
||||
private long max_ram = -1;
|
||||
|
||||
@Option(name = "-rendertime", usage = "Maximum time allow for each frame (in minute)", required = false)
|
||||
private int max_rendertime = -1;
|
||||
|
||||
@@ -256,7 +256,7 @@ public class Settings implements Activity {
|
||||
|
||||
// max ram allowed to render
|
||||
OS os = OS.getOS();
|
||||
int all_ram = os.getMemory();
|
||||
int all_ram = (int) os.getMemory();
|
||||
ram = new JSlider(0, all_ram);
|
||||
int step = 1000000;
|
||||
double display = (double)all_ram / (double)step;
|
||||
@@ -272,7 +272,7 @@ public class Settings implements Activity {
|
||||
ram.setLabelTable(labelTable);
|
||||
ram.setPaintTicks(true);
|
||||
ram.setPaintLabels(true);
|
||||
ram.setValue(config.getMaxMemory() != -1 ? config.getMaxMemory() : os.getMemory());
|
||||
ram.setValue((int)(config.getMaxMemory() != -1 ? config.getMaxMemory() : os.getMemory()));
|
||||
JLabel ramLabel = new JLabel("Memory:");
|
||||
|
||||
compute_devices_constraints.weightx = 1.0 / gpus.size();
|
||||
@@ -558,7 +558,7 @@ public class Settings implements Activity {
|
||||
config.setUseNbCores(cpu_cores);
|
||||
}
|
||||
|
||||
int max_ram = -1;
|
||||
long max_ram = -1;
|
||||
if (ram != null) {
|
||||
max_ram = ram.getValue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user