diagnosing thread leak questions

J

Jeff

Is there some mechanism to identify which class or method created a thread?

My application's thread count increases dramatically heavy loads. At
startup, my application creates 5 threads. However, 10 threads are listed
in the active thread enumeration. Now some of those could be supporting
libraries such as log4j. But once it starts processing load, the thread
count jumps to 26, and eventually gets above 150.

I've called Thread(String arg) when the application explicitly creates
threads so that I can identify the threads the application explicitly
creates. The mystery threads all have high identifier names. For example,

At startup, the threads are called:
Thread-1
Thread-2
Thread-3.

Under load, I see:
Thread-760
Thread-1750

1. Does 760 imply there are 759 previous threads?

2. There are always 3 null entries in the enumeration of active threads.
Is this symptom some discrepency between activeCount() and
Thread.enumerate()?

Here's the method I use to count threads:
public static void listThreads() {
int activeCount = Thread.activeCount();
System.out.println("active thread count: " + activeCount);
Thread[] threads = new Thread[activeCount];
Thread.enumerate(threads);

for ( int j = 0 ; j < threads.length ; j ++ ) {
System.out.println("threads["+ j + "]:" + threads[j]);
}
}

Thanks
 
A

Ann

Jeff said:
Is there some mechanism to identify which class or method created a thread?

My application's thread count increases dramatically heavy loads. At
startup, my application creates 5 threads. However, 10 threads are listed
in the active thread enumeration. Now some of those could be supporting
libraries such as log4j. But once it starts processing load, the thread
count jumps to 26, and eventually gets above 150.

I've called Thread(String arg) when the application explicitly creates
threads so that I can identify the threads the application explicitly
creates. The mystery threads all have high identifier names. For example,

At startup, the threads are called:
Thread-1
Thread-2
Thread-3.

Under load, I see:
Thread-760
Thread-1750

1. Does 760 imply there are 759 previous threads?

2. There are always 3 null entries in the enumeration of active threads.
Is this symptom some discrepency between activeCount() and
Thread.enumerate()?

Here's the method I use to count threads:
public static void listThreads() {
int activeCount = Thread.activeCount();
System.out.println("active thread count: " + activeCount);
Thread[] threads = new Thread[activeCount];
Thread.enumerate(threads);

for ( int j = 0 ; j < threads.length ; j ++ ) {
System.out.println("threads["+ j + "]:" + threads[j]);
}
}

Thanks
I have an app that creates no threads, but there are
some created by the system. I wrote a method to list them.
(d=daemon, *=current, number is prio.)

Thread Group: system
------ 1
Thread 0: d 10 Reference Handler
Thread 1: d 8 Finalizer
Thread 2: d 10 Signal Dispatcher
Thread 3: d 10 CompilerThread0
Thread 4: d 6 AWT-Windows
Thread 5: * 6 AWT-EventQueue-0
Thread 6: 5 AWT-Shutdown
Thread 7: d 10 Java2D Disposer
Thread 8: 5 DestroyJavaVM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top