Results 1 to 4 of 4

Thread: How to properly destroy the application context

  1. #1
    Join Date
    Aug 2006
    Posts
    2

    Default How to properly destroy the application context

    Hi,

    I have an Application context extending AbstractXmlApplicationContext, that contains Hibernate connection. I want to be able to release all the memory held by this proces. I call destroy(), and set the reference to null, but no luck. For illustration, running this block, causes my application to run out of memory.

    Code:
    	BootstrapClassPathXmlApplicationContext context;
    
    		for (int i = 0; i < 1000; i++) {
    			context = new BootstrapClassPathXmlApplicationContext(
    					new String[] { "bootContext-migration.xml" });
    			context.destroy();
    			context = null;
    		}
    It seems that some resources are not being released. Any tips on how to fully destroy the application context?

    Thank you!

  2. #2
    Join Date
    Oct 2004
    Location
    Fareham, England
    Posts
    313

    Default

    Hi

    Which resources exactly are being pinned in memory? Have you used a memory profiler to see what is being pinned in memory and causing said issue?

    Cheers
    Rick

  3. #3
    Join Date
    Aug 2006
    Posts
    2

    Default

    Quote Originally Posted by Rick Evans
    Hi

    Which resources exactly are being pinned in memory? Have you used a memory profiler to see what is being pinned in memory and causing said issue?

    Cheers
    Rick
    I believe my non-heap memory gets filled-up. Setting -XX:PermSize and -XX:MaxPermSize parameters to the JVM, only delays the occurence of the issue, but does not solve the problem.

  4. #4
    Join Date
    Jun 2009
    Posts
    6

    Default

    Hi,

    Does anyone knows how to destroy Spring Application Context?

    I create few resources in application context like RMI objects. When next time I run, I get error saying the port already in use. Then I have to close eclipse and start again for next testing. If I close Eclipse and run again, it does not give problem. But if I run once and run again without closing eclipse, I get error saying port is already in use. The application context does not get destroyed. How do I destroy application context?

Posting Permissions

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