blob: 8ac5dabd422d44e14e84d257f39d25fa2c33646c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
package util;
import fileserv.FileChunk;
public class Constants {
public static final String INCOMPLETE_UPLOAD_SUFFIX = ".part";
public static final int MAX_UPLOADS;
static {
long maxMem = Runtime.getRuntime().maxMemory();
if (maxMem == Long.MAX_VALUE) {
// Apparently the JVM was started without a memory limit (no -Xmx cmdline),
// so we assume a default of 256MB
maxMem = 256l * 1024l * 1024l;
}
maxMem /= 1024l * 1024l;
// Now maxMem is the amount of memory in MiB
MAX_UPLOADS = (int) Math.max(1, (maxMem - 64) / (FileChunk.CHUNK_SIZE_MIB + 1));
}
}
|