我有一個在Tomcat 6上運行的Web應用程序,我使用Netbeans 6.9.1創建了該應用程序,並創建了Entity類和持久性的wizards。它使用Hibernate,MySQL作爲數據庫,Quartz每15分鐘運行一次任務,以及JavaMail。在Hibernate,Quartz和JavaMail應用程序中的Java OutOfMemory
Hibernate配置如下:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="GVPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.test.MyfirstEntity</class>
<class>com.test.MySecondEntity</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.connection.username" value="root" />
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.password" value="password" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/db" />
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider" />
<property name="hibernate.c3p0.acquire_increment" value="1" />
<property name="hibernate.c3p0.idle_test_period" value="300" />
<property name="hibernate.c3p0.timeout" value="100" />
<property name="hibernate.c3p0.max_size" value="100" />
<property name="hibernate.c3p0.min_size" value="0" />
<property name="hibernate.c3p0.max_statements" value="0" />
</properties>
</persistence-unit>
</persistence>
與石英創建的任務,即每15分鐘運行,檢查使用JavaMail(與IMAP)Gmail帳戶,檢索所有的消息,對它們進行處理(長相對於某些信息)並使用Hibernate將具有該信息的對象存儲到數據庫中。然後它將所有郵件標記爲已刪除,因此它們不會在下一次運行中處理。
每次運行此任務時,都會消耗10,20,50MBytes,具體取決於它處理的郵件數量。我查看了MySQL Administrator,並且在不需要時數據庫連接關閉。但是如果我查看進程內存(在運行的Linux機器上),內存會增長,直到達到CPU使用率爲100%的限制,並且Tomcat不再響應。
爲了嘗試不同的解決方案,我更改了幾次-Xms -Xmx和PermGem Size,但它總是達到系統停止工作並且內存未被釋放的地步。
任何想法,我可以開始尋找這個問題?我已經爲Java VM分配了更多的1.5GBytes,即使它持續了一天以上,它也會掛起。
當Tomcat和所有應用程序停止工作時,沒有堆棧跟蹤。
感謝