tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tom Drake" <...@pobox.com>
Subject Re: Tomcat, threads and garbagecleaner: A question
Date Wed, 02 Jan 2002 12:33:26 GMT
Duarte:

Your inactive threads, or any other unreferenced objects will be,
eventually, garbage collected.

Are you sure that your thread actually completes (e.g. falls out the
end of 'run()') ?

Are you certain that you have no hidden references to your objects -
perhaps stored in your session?

Are your objects hanging on to constrained resources too long?
(eg. database connections, input streams, ...)

If every page hit launches a new thread, you are building in a platform
specific limit to the number of concurrent requests your server can handle.
Perhaps you should 'pool' these threads, or simply 'schedule' the code your
thread to be run by some sort of thread scheduler.

Here's a couple of things that you can do to narrow down  the problem:

- add some simple logging in the finalize method of each 'suspect' class.
  This will tell you when your objects are garbage collected.

- add logging to the end of your 'run' methods. This will show you when your
  threads actually 'stop'.

- Write a servlet that lists all ThreadGroups and Threads starting at the
'top'
ThreadGroup (null parent). This will show you what threads are active at the
time your servlet is run.

- 'Debug' your webapp, setting break points in appropriate places.

Good luck

Tom Drake

----- Original Message -----
From: "Duarte Loreto" <happyguy_pt@hotmail.com>
To: <tomcat-user@jakarta.apache.org>
Sent: Tuesday, January 01, 2002 5:45 PM
Subject: Tomcat, threads and garbagecleaner: A question


|    Hello!
|
| I have a JSP page that instantiates an object. This instantiates another
| one, as a thread. The thread is created and started on the same inline,
and
| I have no pointer to the thread.
|
| My question is: when this thread finishes it's run(), does it get
| garbagecleaned? The object that referenced it was created by a JSP page
that
| was already delivered to the client, so it should be, right?
|
| I'm asking this as I have a server that, after some usage, starts to get
| slow and then completly freezes, needing a restart. I suspect that there
is
| a memory leak somewhere, and this seems the most probable place.
|
| If your answer is "the thread gets garbagecleaned, so look elsewhere for
| your problem", I would appreciate help on how to analyse memory usage. I'm
| clueless on this.
|
| I'm using tomcat 3.2.3 and I run it on UNIX, with JDK1.3. If needed be, I
| can put it to run on a Windows, if you tell me that THE tool to check for
| the problem is windows-based
|
| I appreciate your help. If you think that this question shouldn't be
posted
| here but rather on the devel list, please notify me.
|
| Duarte "HappyGuy" Loreto
|
| "Don't worry, be happy!"
|
|
| _________________________________________________________________
| Send and receive Hotmail on your mobile device: http://mobile.msn.com
|
|
| --
| To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
| For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
| Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
|
|
|


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message