-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: PermGen out of memory Error when using with Quickfix/J
PostPosted: Sun Nov 13, 2011 1:02 pm 
Newbie

Joined: Sun Nov 13, 2011 12:25 pm
Posts: 2
I am using Hibernate 3.3.1.GA and initializing it through Spring to write to an Oracle9i database. I am working on an application that uses Quickfix/J to connect out to a fix engine and retrieve trades. Before processing trades we must save off the markets. We are just marshaling the fix message into an object and save it out to the database to be processed by another app. When I just run the app with just logging everything and not calling save() it all runs fine. But when I try to save it to the DB I get this OutOfMemory exception. I have tried simply increasing the memory maximum, I had it to 2G but when viewing the app it at worst when I queue up all of the messages it only consumes 700k but still throws this error.

Code:
java.lang.OutOfMemoryError: PermGen space
     at java.lang.ClassLoader.defineClass1(Native Method)
     at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
     at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
     at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
     at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
     at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
     at org.hibernate.impl.SessionImpl.<init>(SessionImpl.java:236)
     at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:503)
     at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:527)
     at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:535)
     at org.springframework.orm.hibernate3.SessionFactoryUtils.doGetSession(SessionFactoryUtils.java:319)
     at org.springframework.orm.hibernate3.SessionFactoryUtils.getSession(SessionFactoryUtils.java:235)
     at org.springframework.orm.hibernate3.HibernateTemplate.getSession(HibernateTemplate.java:470)
     at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:405)
     at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
     at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:988)
     at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:984)
     at com.tradecapture.etap.dao.IceDAOImpl.getMarket(IceDAOImpl.java:48)
     at com.tradecapture.market.DBMarketDao.findById(DBMarketDao.java:26)
     at com.tradecapture.market.DefaultMarketManager.getMarket(DefaultMarketManager.java:88)
     at com.tradecapture.ice.FixTradeCaptureMessageHandlerIce.onMessage(FixTradeCaptureMessageHandlerIce.java:76)
     at quickfix.fix44.MessageCracker.crack44(MessageCracker.java:1601)
     at quickfix.fix44.MessageCracker.crack(MessageCracker.java:1434)
     at com.tradecapture.ice.FixTradeCaptureMessageHandlerIce.handleIncomingMessage(FixTradeCaptureMessageHandlerIce.java:229

     at com.tradecapture.ice.FixTradeCaptureMessageHandlerIce.fromApp(FixTradeCaptureMessageHandlerIce.java:146)
     at quickfix.Session.fromCallback(Session.java:1647)


Also if any of you are familier with Quickfix here is the exception I get there:

Code:
Exception in thread "QFJ Message Processor" java.lang.OutOfMemoryError: PermGen space
     at java.lang.Throwable.getStackTraceElement(Native Method)
     at java.lang.Throwable.getOurStackTrace(Throwable.java:591)
     at java.lang.Throwable.printStackTrace(Throwable.java:510)
     at org.apache.log4j.spi.LocationInfo.<init>(LocationInfo.java:105)
     at org.apache.log4j.spi.LoggingEvent.getLocationInformation(LoggingEvent.java:191)
     at org.apache.log4j.helpers.PatternParser$ClassNamePatternConverter.getFullyQualifiedName(PatternParser.java:538)
     at org.apache.log4j.helpers.PatternParser$NamedPatternConverter.convert(PatternParser.java:511)
     at org.apache.log4j.helpers.PatternConverter.format(PatternConverter.java:64)
     at org.apache.log4j.PatternLayout.format(PatternLayout.java:503)
     at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:301)
     at org.apache.log4j.DailyRollingFileAppender.subAppend(DailyRollingFileAppender.java:358)
     at org.apache.log4j.WriterAppender.append(WriterAppender.java:159)
     at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:230)
     at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:65)
     at org.apache.log4j.Category.callAppenders(Category.java:203)
     at org.apache.log4j.Category.forcedLog(Category.java:388)
     at org.apache.log4j.Category.log(Category.java:853)
     at org.slf4j.impl.Log4jLoggerAdapter.error(Log4jLoggerAdapter.java:493)
     at quickfix.SLF4JLog.logError(SLF4JLog.java:133)
     at quickfix.SLF4JLog.onErrorEvent(SLF4JLog.java:107)
     at quickfix.LogUtil.logThrowable(LogUtil.java:47)
     at quickfix.LogUtil.logThrowable(LogUtil.java:60)
     at quickfix.mina.SingleThreadedEventHandlingStrategy$SessionMessageEvent.processMessage(SingleThreadedEventHandlingStrategy.java:122)
     at quickfix.mina.SingleThreadedEventHandlingStrategy.block(SingleThreadedEventHandlingStrategy.java:75)
     at quickfix.mina.SingleThreadedEventHandlingStrategy$1.run(SingleThreadedEventHandlingStrategy.java:92)
     at java.lang.Thread.run(Thread.java:662)


The mapping doc here is a beast but pretty simple:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                   "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
   <class name="com.tradecapture.model.Market"
      table="ETAP_ICE_MARKET">
      <id column="ICE_MARKET_ID" name="marketOID" type="long">
         <generator class="sequence">
            <param name="sequence">MARKET_SEQUENCE</param>
         </generator>
      </id>
      <many-to-one class="com.tradecapture.model.MarketType"
         fetch="join" name="marketType" cascade="all">
         <column name="ICE_MARKET_TYPE_ID" />
      </many-to-one>
      <property generated="never" lazy="false" name="underlyingSymbol"
         type="string">
         <column name="UNDERLYING_SYMBOL" />
      </property>
      <property generated="never" lazy="false" name="underlyingSecurityID"
         type="string">
         <column name="UNDERLYING_SECURITY_ID" />
      </property>
      <property generated="never" lazy="false" name="underlyingSecurityIDSource"
         type="string">
         <column name="UNDERLYING_SECURITY_ID_SOURCE" />
      </property>
      <property generated="never" lazy="false" name="underlyingCFICode"
         type="string">
         <column name="UNDERLYING_CFI_CODE" />
      </property>
      <property generated="never" lazy="false" name="underlyingSecurityDesc"
         type="string">
         <column name="UNDERLYING_SECURITY_DESC" />
      </property>
      <property generated="never" lazy="false" name="underlyingMaturityDate"
         type="com.tradecapture.util.StringDateUserType">
         <column name="UNDERLYING_MATURITY_DATE" />
      </property>
      <property generated="never" lazy="false"
         name="underlyingContractMultiplier" type="float">
         <column name="UNDERLYING_CONTRACT_MULTIPLIER" />
      </property>
      <property generated="never" lazy="false" name="underlyingUnitOfMeasure"
         type="string">
         <column name="UNDERLYING_UNIT_OF_MEASURE" />
      </property>
      <property generated="never" lazy="false" name="incrementPrice"
         type="float">
         <column name="INCREMENT_PRICE" />
      </property>
      <property generated="never" lazy="false" name="incrementQty"
         type="float">
         <column name="INCREMENT_QUANTITY" />
      </property>
      <property generated="never" lazy="false" name="incrementStrike"
         type="float">
         <column name="INCREMENT_STRIKE" />
      </property>
      <property generated="never" lazy="false" name="minStrike"
         type="float">
         <column name="MIN_STRIKE" />
      </property>
      <property generated="never" lazy="false" name="maxStrike"
         type="float">
         <column name="MAX_STRIKE" />
      </property>
      <property generated="never" lazy="false" name="lotSize" type="int">
         <column name="LOT_SIZE" />
      </property>
      <property generated="never" lazy="false" name="lotSizeMultiplier"
         type="int">
         <column name="LOT_SIZE_MULTIPLIER" />
      </property>
      <property generated="never" lazy="false" name="clearable"
         type="string">
         <column name="CLEARABLE" />
      </property>
      <property generated="never" lazy="false" name="startDate"
         type="com.tradecapture.util.StringDateUserType">
         <column name="START_DATE" />
      </property>
      <property generated="never" lazy="false" name="endDate"
         type="com.tradecapture.util.StringDateUserType">
         <column name="END_DATE" />
      </property>
      <property generated="never" lazy="false" name="stripId" type="int">
         <column name="STRIP_ID" />
      </property>
      <property generated="never" lazy="false" name="stripName"
         type="string">
         <column name="STRIP_NAME" />
      </property>
      <property generated="never" lazy="false" name="stripType"
         type="int">
         <column name="STRIP_TYPE" />
      </property>
      <property generated="never" lazy="false" name="hubId" type="int">
         <column name="HUB_ID" />
      </property>
      <property generated="never" lazy="false" name="hubName" type="string">
         <column name="HUB_NAME" />
      </property>
      <property generated="never" lazy="false" name="hubAlias"
         type="string">
         <column name="HUB_ALIAS" />
      </property>
      <property generated="never" lazy="false" name="granularity"
         type="string">
         <column name="GRANULARITY" />
      </property>
      <property generated="never" lazy="false" name="priceDenomination"
         type="string">
         <column name="PRICE_DENOMINATION" />
      </property>
      <property generated="never" lazy="false" name="priceUnit"
         type="string">
         <column name="PRICE_UNIT" />
      </property>
      <property generated="never" lazy="false" name="numOfDecimalPrice"
         type="int">
         <column name="NUM_OF_DECIMAL_PRICE" />
      </property>
      <property generated="never" lazy="false" name="numOfDecimalQty"
         type="int">
         <column name="NUM_OF_DECIMAL_QTY" />
      </property>
      <property generated="never" lazy="false" name="tickValue"
         type="float">
         <column name="TICK_VALUE" />
      </property>
      <property generated="never" lazy="false" name="impliedType"
         type="string">
         <column name="IMPLIED_TYPE" />
      </property>
      <property generated="never" lazy="false" name="primaryLegSymbol"
         type="string">
         <column name="PRIMARY_LEG_SYMBOL" />
      </property>
      <property generated="never" lazy="false" name="secondaryLegSymbol"
         type="string">
         <column name="SECONDARY_LEG_SYMBOL" />
      </property>
      <property generated="never" lazy="false" name="productId"
         type="int">
         <column name="PRODUCT_ID" />
      </property>
      <property generated="never" lazy="false" name="productName"
         type="string">
         <column name="PRODUCT_NAME" />
      </property>
      <property generated="never" lazy="false" name="productDescription"
         type="string">
         <column name="PRODUCT_DESC" />
      </property>
      <property generated="never" lazy="false" name="text" type="string">
         <column name="TEXT" />
      </property>
   </class>
</hibernate-mapping>


Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                   "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.tradecapture.model.MarketType" table="ETAP_ICE_MARKET_TYPE">
  <id column="ICE_MARKET_TYPE_ID" name="marketTypeOID" type="long">
   <generator class="sequence">
      <param name="sequence">MARKET_TYPE_SEQUENCE</param>
   </generator>
  </id>
  <property generated="never" lazy="false" name="exchange" type="string">
   <column name="EXCHANGE"/>
  </property>
  <property generated="never" lazy="false" name="name" type="string">
   <column name="NAME"/>
  </property>
  <property generated="never" lazy="false" name="cfiCode" type="string">
   <column name="CFI_CODE"/>
  </property>
</class>
</hibernate-mapping>


Using Spring obviously I don't manage the sessions myself, and in the dao all I do is pass it a market object and call
Code:
getHibernateTemplate().save(market);


And finally my spring context:

Code:
<bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName">
         <value>oracle.jdbc.OracleDriver</value>
      </property>
      <property name="url"><value>jdbc:oracle:thin:@127.0.0.1:1521:xe</value></property>
      <property name="username"><value>${hibernate.connection.username}</value></property>
      <property name="password"><value>${hibernate.connection.password}</value></property>
   </bean>
   
   <!-- Hibernate SessionFactory -->
   <bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="dataSource">
         <ref local="aDataSource" />
      </property>
      <property name="mappingDirectoryLocations" value="hibernate" />
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9iDialect</prop>
            <prop key="hibernate.default_schema">ETAP</prop>
            <prop key="hibernate.connection.pool_size">1</prop>
            <prop key="hibernate.show_sql">true</prop>
         </props>
      </property>
   </bean>


Top
 Profile  
 
 Post subject: Re: PermGen out of memory Error when using with Quickfix/J
PostPosted: Sun Nov 13, 2011 1:39 pm 
Newbie

Joined: Sun Nov 13, 2011 12:25 pm
Posts: 2
Here is another stacktrace that seems a little better, actually showing where it really came from.

Code:
java.lang.OutOfMemoryError: PermGen space
     at java.lang.ClassLoader.defineClass1(Native Method)
     at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
     at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
     at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
     at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
     at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
     at org.hibernate.jdbc.Expectations.<clinit>(Expectations.java:176)
     at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2238)
     at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2688)
     at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
     at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
     at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
     at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
     at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
     at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
     at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
     at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:390)
     at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:420)
     at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
     at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdateAll(HibernateTemplate.java:768)
     at com.tradecapture.etap.dao.IceDAOImpl.insertMarkets(IceDAOImpl.java:37)
     at com.tradecapture.market.DBMarketDao.save(DBMarketDao.java:49)
     at com.tradecapture.market.DefaultMarketManager.saveMarket(DefaultMarketManager.java:115)
     at com.tradecapture.ice.FixTradeCaptureMessageHandlerIce.onMessage(FixTradeCaptureMessageHandlerIce.java:109)
     at quickfix.fix44.MessageCracker.crack44(MessageCracker.java:1510)
     at quickfix.fix44.MessageCracker.crack(MessageCracker.java:1434)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.