On the Internet, I was able to find only the restriction of arguments when starting from the command line.

Is it possible to set a limit inside the code at runtime?

    1 answer 1

    During program execution, it is not possible to adjust the -Xmx and -Xms . They can only be set before starting work.

    But the question arises: why is it necessary? You can choose the appropriate parameters before starting the program. For example, allocate the maximum available memory to the application.

    Or, alternatively, run a new process at runtime and set new JVM parameters.

    • that is, if I write it in the starter - Main (String ... args), then is it the same as setting the arguments on the command line? Will the restriction work? - Katoteshi Fuku
    • No, the arguments in args are the arguments of the application being started, not the virtual machine. An example of starting a new process: java <параметры JVM> -jar app.jar - Pavel Parshin