Results 1 to 5 of 5

Thread: Singleton bean creation slow in 1.2-RC2

  1. #1
    Join Date
    Apr 2005
    Posts
    4

    Default Singleton bean creation slow in 1.2-RC2

    Hi,

    Are other people experiencing an increase in the time required to instantiate simple beans with the new upgrade to 1.2-RC2? It is now taking roughly 15 seconds to instantiate a singleton bean which used to be sub-second.

    The bean definition looks like this:

    <bean id="Test" class="some.org.unit.junit.HibernateTestBean" singleton="true">
    <property name="sessionFactory">
    <ref bean = "sessionFactory"/>
    </property>
    </bean>

    It also seems to be using more memory than before and after running several JUnit tests we are running out of memory (new behavior).

    Thanks

    Tom

  2. #2
    Join Date
    Sep 2004
    Posts
    1,086

    Default Re: Singleton bean creation slow in 1.2-RC2

    Quote Originally Posted by trostelt
    Hi,

    Are other people experiencing an increase in the time required to instantiate simple beans with the new upgrade to 1.2-RC2? It is now taking roughly 15 seconds to instantiate a singleton bean which used to be sub-second.

    The bean definition looks like this:

    <bean id="Test" class="some.org.unit.junit.HibernateTestBean" singleton="true">
    <property name="sessionFactory">
    <ref bean = "sessionFactory"/>
    </property>
    </bean>

    It also seems to be using more memory than before and after running several JUnit tests we are running out of memory (new behavior).

    Thanks

    Tom
    Did you change anything else? Hibernate sessionFactory init itself usually lasts at least 5-10 secs for more then 3-4 tables.

  3. #3
    Join Date
    Apr 2005
    Posts
    4

    Default

    Hmm ... well I did change the depricated method for creating the factory from

    is = new FileInputStream(directory + "/beans.xml");
    factory = new XmlBeanFactory(is);

    to

    is = new FileInputStream(directory + "/beans.xml");
    InputStreamResource ris = new InputStreamResource(is);
    factory = new XmlBeanFactory(ris);

    since the old method was depricated but other than that its pretty much the same. These statements are in the setUp and tearDown sections of the JUnit test classes I am using. For one test I made the factory and the test bean static and then test to see if they are instantiated (singleton) within the test class. The main issue arises from the number of test classes in this project. There are approximately 40+ test scenarios we run through and will likely have more. We can deal with the time issue if this is just a normal increase from the previous version on initialization of internal Hibernate structures but the drain on system memory is more problematic.

    Thanks

    Tom

  4. #4
    Join Date
    Sep 2004
    Posts
    1,086

    Default

    Quote Originally Posted by trostelt
    Hmm ... well I did change the depricated method for creating the factory from

    is = new FileInputStream(directory + "/beans.xml");
    factory = new XmlBeanFactory(is);

    to

    is = new FileInputStream(directory + "/beans.xml");
    InputStreamResource ris = new InputStreamResource(is);
    factory = new XmlBeanFactory(ris);

    since the old method was depricated but other than that its pretty much the same. These statements are in the setUp and tearDown sections of the JUnit test classes I am using. For one test I made the factory and the test bean static and then test to see if they are instantiated (singleton) within the test class. The main issue arises from the number of test classes in this project. There are approximately 40+ test scenarios we run through and will likely have more. We can deal with the time issue if this is just a normal increase from the previous version on initialization of internal Hibernate structures but the drain on system memory is more problematic.

    Thanks

    Tom
    I meant more fundamental changes because I never really saw sub-second Hibernate init times and those times are usually 90+% of the time spent loading the context. If you take a look at the log you should be able to see which part takes so long. (On the project I'm working on right now test context loading lasts 15 secs, out of that Hibernate takes 13 secs for configuration and creating tables in the test db)

    Btw, usually there is no need to load the context for every test. Take a look at AbstractSpringContextTests (it's in spring-mock.jar, not spring.jar)

  5. #5
    Join Date
    Apr 2005
    Posts
    4

    Default

    We're probably experiencing increases due to the change from Hibernate 2 to Hibernate 3 classes also. The code was deliberately written in such a way that the conversion was easy though initialization times aparently are greater in 3.

    Yes it really was sub-second ... cool eh? Sounds like Hibernate 3 spends a lot more time than 2. Thank you for the metrics from your systems. They help put the problem in perspective. I will also take a look at the alternate initialization method. That may be a viable solution.

Similar Threads

  1. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  2. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  3. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •