Java. Lang. outofmemoryerror: permgen SpacePermgen space stands for permanent generation space, which is the permanent storage area of the memory. The region is used by JVM to store class and meta information. The default size of the region is about 4 MB, the JVM zookeeper recycler does not clean up the region during runtime. as the application loads more and more classes (these classes include all the jar files imported from the Lib package), The permgen space error will be thrown when the region is insufficient, at this time, you should manually set the perm size value, for example, java_opts = '-XX: permsize = 64 m-XX: maxpermsize = 128m'. This error often occurs when the application is started, for example, if Tomcat runs too many applications and each application contains a considerable number of lib packages, this error may occur, because the class in each application lib package will occupy a certain amount of memory in this region during loading, even if these applications contain the same jar, the class in these jar files may still occupy different memory areas when loading, therefore, adjusting the permsize is one option. Another good way is to move the same jar package in the application to the Tomcat lib directory, which can reduce the memory usage in the perm area.
Java. Lang. outofmemoryerror: Java heap SpaceThe memory area of the JVM heap, which is a runtime data area used to allocate class objects, such as the new instance objects. this area can be cleared by the garbage collector during running. When JVM is started, the heap size value is automatically set. The initial space (-XMS) is 1/64 of the physical memory, the maximum space (-xmx) is 1/4 of the physical memory. When more and more instance objects are generated during the program running, and these objects are not cleared in time, this error will be thrown until these objects occupy the close-xmx setting value. for example, we save too much information in the Web application session (the session is stored in the server memory). As the number of users increases, each user occupies a certain amount of memory, when a concurrent online user reaches a certain level, this memory overflow error may be thrown, in this case, the most direct solution is to set the size of-xmx (we recommend that you set the size of-XMS as large as that of-xmx ), the other is to check whether your session contains too much unnecessary information. this error often occurs in many background threads. To handle large data volumes, we often create some scheduled tasks in the system, these scheduled tasks may occupy a large amount of memory for a long time. As the number of tasks increases, these threads may cause memory overflow errors without knowing it!
Transferred from [http://www.blogjava.net/huliqing/archive/2013/08/10/402665.html]