I hosted one application UI in apache-tomcat server. I had set environment variables in bin/setenv.sh file as:CATALINA_OPTS=-server -Xms256m -Xmx512m -XX:PermSize=512m -XX:MaxPermSize=1024mEvery time I perform a huge operation,(ex: Generating report with all the data in the application), 'JavaHeapSpace' exception is coming and then on-wards application is not working. Again I have to restart the server.My questions are:What are -Xms and -Xmx?What values should i put for them in-order to avoid JavaHeapSpace exception?What could be the maximum and minimum values for them?If it depends on the server configuration, I have shared my server configuration below. Please make suggestions. I really want to avoid this problem.My Server configuration:RAM : 8GB,Processor: octa core,HardDisk: 500GBLet me know, if you guys need any information on the same.
What is the perfect combination of Environment Variables for Tomcat?
configuration;environment variables;tomcat
What are -Xms and -Xmx?Xms256m ---> Selects a low initial JVM heap size for an application.  So, Xms specifies the amount of memory, in Megabytes, that will be used to start the server.          Xmx512m ---> Selects the maximum JVM heap size permissible for an application. So, Xmx specifies the maximum amount of memory, in Megabytes, that will be dedicated to running the server.What values should i put for them in-order to avoid JavaHeapSpace  exception?This depends not on your system's configuration, but, the kind of application you're targeting execution of. So, all those are un-necessary details provided by you. You should care whether your JVM is 32-bit or the 64-bit one. Like, I have this configuration of JVM for execution of my local minimal nature applications ---> -J-Xms100m -J-Xmx200m -J-XX:PermSize=100m.What could be the maximum and minimum values for them?This is limited by the your system's and the JVM's nature.The maximum theoretical heap limit for the 32-bit JVM is 4G. Due to various additional constraints such as available swap, kernel address space usage, memory fragmentation, and VM overhead, in practice the limit can be much lower. On most modern 32-bit Windows systems the maximum heap size will range from 1.4G to 1.6G. On 32-bit Solaris kernels the address space is limited to 2G. On 64-bit operating systems running the 32-bit VM, the max heap size can be higher, approaching 4G on many Solaris systems.If your application requires a very large heap you should use a 64-bit VM on a version of the operating system that supports 64-bit applications.Check this link to know more about it