# 2 分析问题

Tomcat的Wiki页面中记录过这种问题：

Why does the memory usage increase when I redeploy a web application?

That is because your web application has a memory leak.

A common issue are "PermGen" memory leaks. They happen because the Classloader (and the Class objects it loaded) cannot be recycled unless some requirements are met (*). They are stored in the permanent heap generation by the JVM, and when you redeploy a new class loader is created, which loads another copy of all these classes. This can cause OufOfMemoryErrors eventually.

(*) The requirement is that all classes loaded by this classloader should be able to be gc'ed at the same time.

# 3 解决问题

set MEM_MAX_PERM_SIZE_64BIT=-XX:MaxPermSize=256m
set MEM_MAX_PERM_SIZE_32BIT=-XX:MaxPermSize=256m