diff --git a/src/com/sheepit/client/Configuration.java b/src/com/sheepit/client/Configuration.java index 172d703..0cab236 100644 --- a/src/com/sheepit/client/Configuration.java +++ b/src/com/sheepit/client/Configuration.java @@ -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; } diff --git a/src/com/sheepit/client/Server.java b/src/com/sheepit/client/Server.java index e6b7183..0ec1860 100644 --- a/src/com/sheepit/client/Server.java +++ b/src/com/sheepit/client/Server.java @@ -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; } diff --git a/src/com/sheepit/client/SettingsLoader.java b/src/com/sheepit/client/SettingsLoader.java index 553bc87..56579e8 100644 --- a/src/com/sheepit/client/SettingsLoader.java +++ b/src/com/sheepit/client/SettingsLoader.java @@ -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) { diff --git a/src/com/sheepit/client/os/FreeBSD.java b/src/com/sheepit/client/os/FreeBSD.java index 43f0f28..ebfe3dc 100644 --- a/src/com/sheepit/client/os/FreeBSD.java +++ b/src/com/sheepit/client/os/FreeBSD.java @@ -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; } diff --git a/src/com/sheepit/client/os/Linux.java b/src/com/sheepit/client/os/Linux.java index e9f8a5a..34db43f 100644 --- a/src/com/sheepit/client/os/Linux.java +++ b/src/com/sheepit/client/os/Linux.java @@ -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)); diff --git a/src/com/sheepit/client/os/Mac.java b/src/com/sheepit/client/os/Mac.java index 0d1bd34..da75483 100644 --- a/src/com/sheepit/client/os/Mac.java +++ b/src/com/sheepit/client/os/Mac.java @@ -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; } diff --git a/src/com/sheepit/client/os/OS.java b/src/com/sheepit/client/os/OS.java index 5430398..55e48d6 100644 --- a/src/com/sheepit/client/os/OS.java +++ b/src/com/sheepit/client/os/OS.java @@ -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(); diff --git a/src/com/sheepit/client/os/Windows.java b/src/com/sheepit/client/os/Windows.java index 905f038..f897ade 100644 --- a/src/com/sheepit/client/os/Windows.java +++ b/src/com/sheepit/client/os/Windows.java @@ -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) { diff --git a/src/com/sheepit/client/standalone/Worker.java b/src/com/sheepit/client/standalone/Worker.java index 550f445..c1b8313 100644 --- a/src/com/sheepit/client/standalone/Worker.java +++ b/src/com/sheepit/client/standalone/Worker.java @@ -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; diff --git a/src/com/sheepit/client/standalone/swing/activity/Settings.java b/src/com/sheepit/client/standalone/swing/activity/Settings.java index 263fbb8..2ea7dfd 100644 --- a/src/com/sheepit/client/standalone/swing/activity/Settings.java +++ b/src/com/sheepit/client/standalone/swing/activity/Settings.java @@ -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(); }