ui: maximum allocated jvm memory configurable in preferences
* added setting for maximum memory allocated by JVM to Preferences window. * a value of -1 ignores this setting * changed default value for this setting to -1 * increased JNI version to Java 1.8 * disabled some file system tests for windows
This commit is contained in:
@@ -42,18 +42,24 @@ void JavaEnvironmentFactory::createInstance(std::string classPath, std::string&
|
||||
|
||||
s_classPath = classPath;
|
||||
|
||||
const int jvmMaximumMemory = ApplicationSettings::getInstance()->getJavaMaximumMemory();
|
||||
const int optionCount = (jvmMaximumMemory < 0 ? 2 : 3);
|
||||
const std::string maximumMemoryOprionString = "-Xmx" + std::to_string(jvmMaximumMemory) + "m";
|
||||
|
||||
JavaVM* jvm = nullptr; // Pointer to the JVM (Java Virtual Machine)
|
||||
JNIEnv* env = nullptr; // Pointer to native interface
|
||||
|
||||
JavaVMInitArgs vm_args; // Initialization arguments
|
||||
JavaVMOption* options = new JavaVMOption[3]; // JVM invocation options
|
||||
JavaVMOption* options = new JavaVMOption[optionCount]; // JVM invocation options
|
||||
std::string classPathOption = "-Djava.class.path=" + classPath;
|
||||
options[0].optionString = const_cast<char*>(classPathOption.c_str());
|
||||
options[1].optionString = const_cast<char*>("-Xms64m");
|
||||
std::string maximumMemoryOprionString = "-Xmx" + std::to_string(ApplicationSettings::getInstance()->getJavaMaximumMemory()) + "m";
|
||||
options[2].optionString = const_cast<char*>(maximumMemoryOprionString.c_str());
|
||||
vm_args.version = JNI_VERSION_1_6;
|
||||
vm_args.nOptions = 3;
|
||||
if (optionCount == 3)
|
||||
{
|
||||
options[2].optionString = const_cast<char*>(maximumMemoryOprionString.c_str());
|
||||
}
|
||||
vm_args.version = JNI_VERSION_1_8;
|
||||
vm_args.nOptions = optionCount;
|
||||
vm_args.options = options;
|
||||
vm_args.ignoreUnrecognized = false; // invalid options make the JVM init fail
|
||||
|
||||
|
||||
Reference in New Issue
Block a user