Is there a way to make it so you can set memory usage arguments inside a java class, not using eclipse or a java program compiler, just simple code that you can do inside a class using notepad or something.
If you don’t know what I mean, Here’s an example:
public class Example {
public Example() {
-Xmx("1024M");
}
public static void main(String args[]) {
new Example();
}
}
Please help, thank you!
Note: I don’t want to make a cmd/batch file to run it with -Xmx!
The memory cannot be changed at run-time (by the time the JRE gets to your code statement, the memory has been set & cannot be changed). The only way to achieve a different memory size is to relaunch the app. using a
Processspecifying larger memory (then close the original app. that does not have enough).Of course, better to simply specify the required memory in the launch process (BAT file, JWS etc.).