I have a java application form which i am accessing records from database,processing it and again updaing the database.
I am doing this by converting my java application to JAR and executing it from command prompt.During testing there are only 20 records
per table in database.For that i am executing the jar as follows to avoid out of memory error,
java -jar -Xmx512m MyApp.jar
If database contains much record(50,000),how to increase the heap size while executing jar or How to increase the heap size dynamically based on needs while executing the jar.
Thanks
The maximum is the maximum heap you would need ever not how much it will actually use. It’s the point at which you would rather than application crash than keep running. The JVM will dynamically manage the memory used up to this point.
So if you want the JVM to use 256 MB, but you want it to dynamically grow up to 30 GB you would set it like this
Even the minimum is not guaranteed to be used. The JVM will do minimal effort to keep the memory usage up to this level. A Hello World program will not use 256 MB of heap no matter what you set the minimum to.