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

@@ -287,7 +287,15 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
HttpURLConnection connection = null;
try {
OS os = OS.getOS();
String url = String.format("%s?computemethod=%s&cpu_cores=%s&ram_max=%s&rendertime_max=%s", this.getPage("request-job"), this.user_config.computeMethodToInt(), ((this.user_config.getNbCores() == -1) ? os.getCPU().cores() : this.user_config.getNbCores()), this.user_config.getMaxMemory(), this.user_config.getMaxRenderTime());
int maxMemory = this.user_config.getMaxMemory();
int freeMemory = os.getFreeMemory();
if (maxMemory < 0) {
maxMemory = freeMemory;
}
else if (freeMemory > 0 && maxMemory > 0) {
maxMemory = Math.min(maxMemory, freeMemory);
}
String url = String.format("%s?computemethod=%s&cpu_cores=%s&ram_max=%s&rendertime_max=%s", this.getPage("request-job"), this.user_config.computeMethodToInt(), ((this.user_config.getNbCores() == -1) ? os.getCPU().cores() : this.user_config.getNbCores()), maxMemory, this.user_config.getMaxRenderTime());
if (this.user_config.getComputeMethod() != ComputeType.CPU && this.user_config.getGPUDevice() != null) {
String gpu_model = "";
try {