You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Duarte Loreto <ha...@hotmail.com> on 2002/01/02 02:45:43 UTC
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: <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>
Re: Tomcat, threads and garbagecleaner: A question
Posted by Tom Drake <rt...@pobox.com>.
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" <ha...@hotmail.com>
To: <to...@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: <ma...@jakarta.apache.org>
| For additional commands: <ma...@jakarta.apache.org>
| Troubles with the list: <ma...@jakarta.apache.org>
|
|
|
--
To unsubscribe: <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>