Below is the test program derived from tutorial.Main.java
It will repeated bring merlin up and down. 
The memory usage in windows task mgr or linux's top keeps growing.


public class Main 
{
   private static Object       m_kernel            = null;
   
   public static void main( String[] args ) throws Exception
    {
       int loop = args.length>0  ? Integer.parseInt( args[0] ) : 10;
       while( --loop>0 )
       {
           System.out.println("\r\ncount down:" + loop );
           startUpMerlin();
           stop();
       }
      System.exit(0);
    }

    public static void startUpMerlin( ) throws Exception
    {
        InitialContextFactory initial = new
DefaultInitialContextFactory( "merlin", new File("c:/tmp/") );
        File home = initial.getHomeDirectory();
        initial.setCacheDirectory( new File( home, "system" ) );
        InitialContext context = initial.createInitialContext();
        String spec = "artifact:merlin/merlin-impl#3.3.0";
        Artifact artifact = Artifact.createArtifact( spec );
        Builder builder = context.newBuilder( artifact );
        Factory factory = builder.getFactory();
        Map criteria = factory.createDefaultCriteria();
        m_kernel = factory.create( criteria );
        System.out.println("Merlin is up.");

    }

    public static synchronized void stop()
    {
        try
        {
            if( m_kernel != null)
            {
                m_kernel.getClass().getMethod("shutdown",
null).invoke(m_kernel, null);
                m_kernel = null;                
                System.out.println("Merlin stopped.");                
            }
            else
                System.out.println("Merlin is not yet online");
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}


On Tue, 21 Sep 2004 08:40:03 +0200, Stephen McConnell
<[EMAIL PROTECTED]> wrote:
> 
> 
> I'm going to throw a little test case
> 
> > -----Original Message-----
> > From: rakesh bhakta [mailto:[EMAIL PROTECTED]
> > Sent: 20 September 2004 16:42
> > To: [EMAIL PROTECTED]
> > Subject: Growing memory footprint
> >
> > I am using merlin (artifact:merlin/merlin-impl#3.3.0") in an embedded
> > style.  My application has a "restart" feature that calls the shutdown
> > method of the current kernel, and then recreate it with
> > factory.create(criteria).
> >
> > At issue is the memory foot print after each restart.  It keeps
> growing at
> > about 8 to 10 Megs per restart.  Eventually, if enough restart occurs,
> JVM
> > runs out of memory in my memory constrained application.
> >
> > Could this behavior be due to Merlin ?
> > Could Merlin be hanging on to something after shutdown method is
> called?
> > Is there any cleanup I should due after shutdown method is called?
> 
> I need to check but there is a reference to the kernel held by a
> shutdown hook - I'm just wondering if that is potentially keeping the
> kernel in memory.
> 
> Steve.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to