I use the decompressed version of tomcat6.0 as an example.
Because my project is cached in tomcat (6.0), the default memory configuration of tomcat will cause OutOfMemoryError: Java heap space, that is, the memory is insufficient.
Here we need to divide the situation
1. If you use tomcat to directly publish a project, find the catalina. bat file in the bin directory of tomcat and open it. Add the following sentence at the top:
Set JAVA_OPTS =-Xms256m-Xmx512m.
You can.
2. When we use eclipse for development, add the following sentence in catalina. bat under the bin directory of tomcat:
Set JAVA_OPTS =-Xms256m-Xmx512m.
Invalid.
In Eclipse:
Choose Window --> Preferences --> Java --> Installed JREs, select the currently used JRE, and click Edit --> Default VM Arguments:
Enter a parameter for the local memory. For example, you can set it to-Xms30m-Xmx512m for a 1 GB machine, and restart Tomcat.
Print tomcat memory information in jsp or serlvet and action to view the memory configuration of tomcat.
For example, write a test action in the action.
public ActionForward test(ActionMapping mapping, ActionForm form1,HttpServletRequest request, HttpServletResponse response)throws Exception {System.out.println("TotalMemory :::: "+ (Runtime.getRuntime().totalMemory() / (1024 * 1024) + "M"));System.out.println("Max Memory :::: "+ (Runtime.getRuntime().maxMemory() / (1024 * 1024) + "M"));System.out.println("Free Memory :::: "+ (Runtime.getRuntime().freeMemory() / (1024 * 1024) + "M"));return null;}
After tomcat is started, access the test to view the print information.
Here, the action is http: // localhost: 8080/aisvoyage/publicAction. do? Operator = test
Print result:
Totalmemory :::: 29 m
Max memory ::: 494 m
Free memory :::: 17 m
The setting is successful.
3. If you unzip tomcat to the windows system service. Here, I add two tomcat servers to the system service as an example.
The script added as a service is
3. 1. decompress the two Tomcat files to the directory on the D Drive: tomcat1 and tomcat2, respectively.
. Compile a BAT file such as installtomcat. bat.
The content is as follows:
Rem install the ikeat1 Service
Set CATALINA_BASE = D: \ tomcat1
Set CATALINA_HOME = D: \ tomcat1
Call D: \ cmdat1 \ bin \ service. bat install cmdat1
Rem install the Tomcat 2 Service
Set CATALINA_BASE = D: \ tomcat2
Set CATALINA_HOME = D: \ tomcat2
Call D: \ tomcat2 \ bin \ service. bat install tomcat2
3.3: provides two Tomcat System services to facilitate operations such as start, stop, and restart.
The delete system command is: SC Delete service name. If the service name contains spaces, the service name is enclosed by quotation marks.
After the service is successfully added, open the Registry win + r and enter regedit to find it.
HKEY_LOCAL_MACHINE \ SOFTWARE \ Apache Software Foundation \ Procrun 2.0 \ paiat1 \ Parameters \
On the right side is the parameter list. The default value is initial 128 M. The maximum value is 256 M.
Jvmms is the size of memory occupied by Tomcat initialization.
Jvmmx is the maximum memory occupied by Tomcat.
Double-click and modify it in decimal format to restart Tomcat's system service!
For Tomcat 5
HKEY_LOCAL_MACHINE \ SOFTWARE \ Apache Software Foundation \ Tomcat Service Manager \ Tomcat5 \ Parameters \ JavaOptions
Append-Xms300m-Xmx350m
4. Tomcat port does not conflict. You need to set each Tomcat listening port to exclusive and unique.
Three ports need to be modified in Tomcat/CONF/server. xml.
4.1. <server port = "8005" shutdown = "shutdown"> the port must be changed to a unique
4.2 <Connector port = "8080" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443"/> the port must be changed to a unique
4.3 <Connector port = "8009" protocol = "AJP/1.3" redirectPort = "8443"/> the port must be changed to a unique
Record it here for future use and reference for new users ..
Good lucky