3 Replies Latest reply on Aug 31, 2003 3:22 AM by Jon Barnett

    debug a servlet

    zohar Newbie

      I have a servlet that runs on jboss 3.08 . When it runs for a while, the JVM starts consuming memory, so I want to debug it. How can I debug it using IntelliJ IDEA (Aurora)?
      Alternatively, how can I see why memory is being consumed? doesn't all memory get freed when the servlet returns its HTTP response?


        • 1. Re: debug a servlet
          Jon Barnett Master

          I'm not sure how you would debug with IntelliJ so someone else would need to step in for that one.

          A servlet instance does not disappear when a request is complete. Usually it (the servlet object) is cached in memory until the next request for the servlet arrives. This enables better response, rather than creating a new servlet every time a request arrives. So only local objects in the servlet methods can be relied upon to be destroyed after use.

          Sessions and their associated objects exist and are also not destroyed until a session expires. Sessions track a user and allow "state variables" to persist between pages. If you have a long expiry time for sessions or no expiry time for sessions, this will implement a memory leak in that no memory used by a session will be reclaimed. Typically, a session is configured by default for 30 minutes.

          Perhaps more detail on the problem you have might help folks here.

          • 2. Re: debug a servlet
            zohar Newbie

            first of all - thanks.
            second - where can i read more about how a servlet behaves?
            third - where can i see to what value the session expiration is set? how can I cahnge it?

            • 3. Re: debug a servlet
              Jon Barnett Master

              The servlet specs are available from Sun.

              Some simple tutorials that have the essentials are:

              Otherwise there are plenty of books on developing servlets and they cover the lifecycle.

              The SAR for your embedded servlet container will have the default session timeout configuration within the global deployment definitions. The definitions will be either in web.xml or webdefault.xml, depending on whether you are using Tomcat or Jetty, respectively. http://jakarta.apache.org/tomcat or http://jetty.mortbay.org for information on the configuration information contained in these.