I used Tomcat 7 for deploy the applications. I execute below code for get the OutOfMemory error.
Long maxMemorySize = Runtime.getRuntime().maxMemory();
model.addAttribute("memorySize",maxMemorySize);
int[] matrixArr = new int[(int) (maxMemorySize + 1)];
for(int i = 0; i < matrixArr.length; ++i)
matrixArr[i] = i+1;
After error is appear, I create a setenv.sh file in tomcat/bin and add below code in it.
export CATALINA_OPTS="-Xms512M -Xmx1024M"
Then restart the Tomcat server and re-execute the programme. But again OutOfMemory error appear. I change the parameters of CATALINA_OPTS, but it doesn't work. And also add below code in setenv.sh file, but it also doesn't work.
export JAVA_OPTS="-Xms512M -Xmx1024M"
Please help me to solve this issue.