Problems with Manager reload, memory usage and garbage collection.

2002-02-15 Thread Thomas Åhlen

Each time I reload my application with the Manager servlet the memory usage
increase.

Spec: I have Tomcat 4.0.2 and JDK 1.3.1_02 running on a Windows2k machine.

I have located my problem using JProbe with Tomcat 4.0.2. Looking at the
instance summary before and after a reload I see that there is one class
that isn't GC'd. So after 10 reloads I have 10 instances of this class. The
class is a singelton and lookes something like this:

public class MySingelton
{
private static MySingelton singelton;

private Hashtable resources;

private MySingelton()
{
// Create a Hashtable with some resources here
}

public static Object getResource( String name )
{
 return resources.get( name );
}

public static synchronized void configure()
{
singelton= new MySingelton();
}
}

This Singelton are only called in the init method of my servlet; e.g.

public void init( ServletConfig config )
throws ServletException
{
MySingelton.configure();
}


I guess that Tomcat sets up a new ClassLoader each time an application is
reloaded. So why can't MySingelton be garabage collected? Somewhere there
must still be a reference to it and it isn't in my code for sure.

Please anyone got a suggestion how to solve my problem?

Thanks!
Thomas Åhlén



--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: Problems with Manager reload, memory usage and garbage collection.

2002-02-15 Thread Thomas Åhlen

  Each time I reload my application with the Manager servlet the
  memory usage
  increase.
 
  Spec: I have Tomcat 4.0.2 and JDK 1.3.1_02 running on a Windows2k
machine.
 
  I have located my problem using JProbe with Tomcat 4.0.2. Looking at the
  instance summary before and after a reload I see that there is one class
  that isn't GC'd. So after 10 reloads I have 10 instances of this
  class. The
  class is a singelton and lookes something like this:
 
  public class MySingelton
  {
  private static MySingelton singelton;
 

 Above is the reference that don't let your class to be GC'ed.
 You should add something like close() to your class

 public void close() {
 singleton = null;
 }
 and then call it in your servlet's destroy()



So simple!! Many thanks :).
Have never had to reload applications with singelton objects before.

Thomas




--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Servlet deployment without using web.xml?!

2002-01-18 Thread Thomas Åhlen

This is what I want to do:

1. First I define one servlet(Controller) in the web.xml file
2. I want my Controller servlet to be able to add and remove
servlets(modules) from the application context.

Why? In my system each servlet is a module and I want my modules to be
pluggable. e.g. possible to add and remove modules(servlets) thru the
Controller servlet. Today I have to change the web.xml file and reload the
application every module I add/remove.

Is this possible? I would see no reason to why there couldn't be some
interface between Tomcat and my servlet that could do this.

Thanks for any suggestions

Thomas Åhlen



--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: Servlet deployment without using web.xml?!

2002-01-18 Thread Thomas Åhlen


 Have you considered having your controller servlet dispatch
to regular old Java code instead of to other servlets? That
way you can have full control and still stay within the
servlet spec.

Yes that is an option but it would require something like this

http://mydomain.com/Controller?module=Authaction=Login

and I want to use

http://mydomain.com/Auth?action=Login


 Otherwise, you're going to have to dig into Tomcat's
internals. Which is nonportable but fun. Assuming you want
to mess with Tomcat 4 and haven't already got the source,
go online and browse the code through CVS. Take a look at
org.apache.catalina.servlets.InvokerServlet and org.apache
catalina.core.StandardContext. That's what your up against.

Thanks will take a look :). Sounds fun!

Thomas




--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]