java - How to set Heap Space for non executable JAR using JNI -
currently working on mac application in getting outofmemoryerror frequently. using non executable jar file our application cannot set heap size before starting application because java code execute using jni, there possible way set heap size using jni or c.
or other solution above problem. in advance.
i found answer. using jni before creating jvm must fill javavmoption parameter "-xms256m" minimum size , "-xmx512m" maximum size. allocate minimum jvm heap size 256 mb , maximum jvm heap size 512 mb.
so code others:
javavminitargs args; javavmoption options[3]; args.noptions = 3; options[0] = (char*)"-xms256m"; options[1] = (char*)"-xmx512m"; options[2] = //your jar file path. args.options = options;
then pass args (javavminitargs object) while creating jvm. above code set minimum , maximum heap size.
remember 1 more thing not set minimum heap size before setting maximum heap size because in case minimum heap size more or equal maximum heap size , crash.
Comments
Post a Comment