java大量内存泄漏
目前维护一个项目,数据库连接了2个,一个Mysql,一个oracle。
原始的项目是只连接了oracle,由于后面需求增加了,又连接了一个mysql.
oracle的部分用hibernate
mysql的部分用的spring,jdbctemplate
注意红色部分没有用hibernate。
不知道这样配置可以否?
这样的配置会造成项目运行一天左右就会内存溢出。
如果我把红色部分去掉则不会内存溢出。
请问连接同一个数据库可以用2个不同的持久层吗?
以下配置又出现什么样的错误?
请指教!
配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<!--<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"-->
<!--"http://www.springframework.org/dtd/spring-beans.dtd">-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:DataBase.properties</value>
</list>
</property>
</bean>
<bean id="transactionManager2"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource1" />
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- Transaction template for Managers -->
<bean id="txProxyTemplate" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="transactionManager" />
<property name="proxyTargetClass">
<value>true</value>
</property>
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="relation*">PROPAGATION_REQUIRED</prop>
<prop key="disconnect*">PROPAGATION_REQUIRED</prop>
<prop key="assign*">PROPAGATION_REQUIRED</prop>
<prop key="unassign*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_SUPPORTS,readOnly</prop>
</props>
</property>
</bean>
<bean id="dataSource1"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName">
<value>${db.driver}</value>
</property>
<property name="url">
<value>${db.url}</value>
</property>
<property name="username">
<value>${db.username}</value>
</property>
<property name="password">
<value>${db.password}</value>
</property>
<property name="initialSize">
<value>${db.pool.initial}</value>
</property>
<property name="maxActive">
<value>${db.pool.max}</value>
</property>
<property name="defaultAutoCommit" value="false" />
</bean>
<bean id="dataSource"
class="org.logicalcobwebs.proxool.ProxoolDataSource">
<property name="driver">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="driverUrl">
<value>
jdbc:oracle:thin:@localhost:1521:DB?useUnicode=true:characterEncoding=UTF-8
</value>
</property>
<property name="user">
<value>USER</value>
</property>
<property name="password">
<value>i123321</value>
</property>
<property name="alias">
<value>ITVDB</value>
</property>
<property name="delegateProperties">
<value>user=USER,password=i123321</value>
</property>
<property name="houseKeepingSleepTime">
<value>90000</value>
</property>
<property name="prototypeCount">
<value>5</value>
</property>
<property name="maximumConnectionCount">
<value>100</value>
</property>
<property name="minimumConnectionCount">
<value>10</value>
</property>
<property name="trace">
<value>true</value>
</property>
<property name="verbose">
<value>true</value>
</property>
</bean>
<bean id="jdbcTemplate"
class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="sessionFactory" lazy-init="true"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>
com/ffcs/itv/resources/program/Catalog.hbm.xml
</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.cache.provider_class">
org.hibernate.cache.OSCacheProvider
</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.dialect">
org.hibernate.dialect.HSQLDialect
</prop>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">
true
</prop>
<prop key="hibernate.proxool.xml">proxool.xml</prop>
<prop key="hibernate.proxool.pool_alias">ITVDB</prop>
</props>
</property>
</bean>
<!-- catalogService bean definition -->
<bean id="catalogDao"
class="com.ffcs.itv.program.dao.impl.CatalogDAOImpl"
lazy-init="true">
<property name="jdbcTemplate">
<ref local="jdbcTemplate" />
</property>
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<bean id="catalogService" parent="txProxyTemplate"
lazy-init="true">
<property name="target">
<bean
class="com.ffcs.itv.program.service.impl.CatalogServiceImpl">
<property name="catalogDao">
<ref local="catalogDao" />
</property>
</bean>
</property>
</bean>
<!-- ClientUserDaoImpl bean definition -->
<bean id="clientUserDao"
class="com.ffcs.itv.program.dao.impl.ClientUserDaoImpl"
lazy-init="true">
<property name="jdbcTemplate">
<ref local="jdbcTemplate" />
</property>
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<bean id="clientUserService" parent="txProxyTemplate"
lazy-init="true">
<property name="target">
<bean
class="com.ffcs.itv.program.service.impl.ClientUserServiceImpl">
<property name="clientUserDao">
<ref local="clientUserDao" />
</property>
</bean>
</property>
</bean>
<!-- ClientUserDaoImpl bean definition -->
<bean id="loginLogDao"
class="com.ffcs.itv.program.dao.impl.LoginLogDAOImpl"
lazy-init="true">
<property name="jdbcTemplate">
<ref local="jdbcTemplate" />
</property>
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<!-- ipconfig -->
<bean id="ipDao"
class="com.ffcs.itv.program.dao.impl.IpConfigDaoImpl">
<property name="jdbcTemplate">
<ref local="jdbcTemplate" />
</property>
</bean>
<bean id="ipService" parent="txProxyTemplate" lazy-init="true">
<property name="target">
<bean
class="com.ffcs.itv.program.service.impl.IpConfigServiceImpl">
<property name="ipDao">
<ref local="ipDao" />
</property>
</bean>
</property>
</bean>
<bean id="loginLogService" parent="txProxyTemplate"
lazy-init="true">
<property name="target">
<bean
class="com.ffcs.itv.program.service.impl.LoginLogServiceImpl">
<property name="dao">
<ref local="loginLogDao" />
</property>
</bean>
</property>
</bean>
<bean id="iptvBaseDao"
class="com.sn.xmitv2010.manage.dao.Impl.ImspContentBaseDaoImpl">
<property name="dataSource">
<ref local="dataSource1" />
</property>
</bean>
<bean id="iptvBaseService" parent="txProxyTemplate"
lazy-init="true">
<property name="target">
<bean
class="com.sn.xmitv2010.manage.service.Impl.ImspContentBaseServiceImpl">
<property name="iptvBaseDao">
<ref local="iptvBaseDao" />
</property>
</bean>
</property>
</bean>
<bean id="accountDao"
class="com.ffcs.itv.program.dao.impl.IptvAccountDaoImpl">
<property name="jdbcTemplate">
<ref local="jdbcTemplate" />
</property>
</bean>
<bean id="accountService" parent="txProxyTemplate"
lazy-init="true">
<property name="target">
<bean
class="com.ffcs.itv.program.service.impl.IptvAccountServiceImpl">
<property name="accountDao">
<ref local="accountDao" />
</property>
</bean>
</property>
</bean>
</beans>