So far,I encountered three situations using tomcat:First, using eclipse, tomcat is configured in eclipse. Second, deploy the project directly in tomcat.Third, install tomcat as a windows service.
In these three cases,An outofmemoryerror appears. How do I fix it?Here I have to mention that I was miserable by those irresponsible articles on the Internet.Various methods of setting memory have been tried,But it doesn't work.The following methods I have described are all my own experiments,no problem.
The first case:
Pictured:I framed it with a red frame.Where xms and xmx are parameters that increase the initial heap size and maximum heap size of the java virtual machine,Mainly to solve the cause caused by insufficient java heap space.xx:permsize and xx:maxpermsize are parameters that increase the initial permanent storage area size and the maximum permanent storage area size.The main solution uses a large number of jars or classes, and the Java virtual machine does not have enough space to load classes.Related to permanent generation space.
The second case:Put the compiled project directly in tomcat, and use startup.bat to start tomcat service. In the bin folder of tomca as follows:
In this situation,We want to modify the parameters in catalina.bat.Open it. Find these two sentences:
rem guess catalina_home if not defined
set "current_dir =%cd%"
Add this sentence to these two sentences,Must be above:set "java_opts=-xms512m -xmx1024m -xx:permsize=256m -xx:maxpermsize=512m"
A lot of similar online,But I tried a lot,It ’s important to note:its location,And quotes and more.
The third case:
If your tomcat is registered as a windows service and started as a service,Then the above method will not work.Because at this time the tomcat startup is to read the parameters of the registry,Instead of reading the parameters of the batch file,At this time we come to set the jvm parameters like this. :Find tomcat7w.exe in the bin directory of tomcat and open:
Under the java option:the initial memory pool below is the initial heap memory size,The maximun memory pool is the maximum heap memory size.To set the size of the perm gen pool, add parameters in the java optionAdd in:
-djava.endorsed.dirs =%tomcat_home%\ endorsed
-djava.io.tmpdir =%tomcat_home%\ temp
-duser.timezone=gmt + 08
(No spaces after each line) I tried this method,It works. You can also add parameters directly in the registry.This will not be introduced,I haven't tried it myself.
In fact, it is not difficult to solve the problem of tomcat memory.Rare is how do you know that this is caused by tomcat memory overflow exception.We have troubled this issue for a long time.If you use eclipse, the console will print an error message,Then it can be judged directly as outofmemoryerror. If it is directly deployed in tomcat and started with startup.bat, you can also see the printed error message.But we just installed the tomcat service into a windows service, so we don't see any error prompts.After the project is launched,Always waitingVery slow very slow,Confusing Is catching up with the database and going on strike,Always thought it was a database problem.In a word:lack of experience.
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- python 3x - typeerror: 'method' object is not subscriptable
- i want to call a child component method from a parent in vuejs
- xcode - pod install [!] no `podfile 'found in the project directory
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file