Why an executable jar when run from a command line uses much more RAM – in my case around 7 time more – than the same project run from Eclipse?
While developing the project I run the application from Eclipse (Run->Run) it used around 60mb (I looked at the just created javaw.exe process) of ram, whereas if I create an executable JAR and run it from command line (Windows) the ram usage is about 450mb. Also, the amplitude of ram usage change is more when run from the command line, than from Eclipse’s Run->Run.
This is probably to do with the JVM settings that Eclipse launches the application with. When launching the Jar, Java will make a best guess at what settings to use in terms of memory. You can change the size of the memory used with the the
javacommand on the console:-Xms??msets the minimum heap size in mb.-Xmx??msets the maximum heap size in mb.Java is probably automatically choosing a larger heap size automatically as it is not being dictated by eclipse.