我使用简单的网络应用程序:
1-Spring mvc4.1.1
2-hibernate 4.3.10
3-servlet 3.1
4-Oracle 12c
5-Ojdbc6(它存在于app / lib中的tomcat / lib中)
6-JPA 2.1
我的持久性xml是:
<?xml version="1.0" encoding="UTF-8"?>
<persistence-unit name="NewpersistenceUnit">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<mapping-file>com/springapp/mvc/DBManagement/EntityMapping.xml</mapping-file>
<class>com.springapp.mvc.DBManagement.StateEntity</class>
<properties>
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@//localhost:1521/orcl"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/>
<property name="hibernate.connection.username" value="system"/>
<property name="hibernate.connection.password" value="1234546"/>
<property name="hibernate.archive.autodetection" value="class"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hbm2ddl.auto" value="update"/>
<property name="hibernate.connection.oracle.jdbc.V8Compatible" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
</properties>
</persistence-unit>
插入方法是
public void AddLocation()
{
EntityManagerFactory emf= Persistence.createEntityManagerFactory("NewpersistenceUnit");
EntityManager em= emf.createEntityManager();
EntityTransaction et= em.getTransaction();
LocationEntity location = new LocationEntity();
location.setCityname("Newyork");
et.begin();
em.persist(location);
et.commit();
em.close();
}
当我在tomcat8.0.26中部署和取消部署并使内存泄漏时 请帮帮我
答案 0 :(得分:2)
根据我的经验,这在大多数情况下是由对tomcats WebappClassLoader的现有强引用引起的。其中一个使用过的库或您的应用程序强烈引用WebappClassLoader,以防止WebappClassLoader被垃圾回收。 可以按照以下步骤跟踪此类内存泄漏:
以下是更详细的说明:How to analyze leaky webapps