This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes how to reduce number of native threads in proc table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "how to reduce number of native threads in proc table" Watch "how to reduce number of native threads in proc table" New topic
Author

how to reduce number of native threads in proc table

Andreas Niemeyer
Greenhorn

Joined: Dec 13, 2005
Posts: 4
Dear all

I'm fighting with remaining native threads for an server application.

By monitoring the process list with "ps -auxw" I noticed many threads of the same application are there. The server starts with 12 processes and after a while more then 100 processes are up, no socket connections still remains.

The Linux JRE version is

java version "1.4.2_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)

Comparing between two linux systems, Debian and Suse, shows me a different behavior, under Debian the native threads falls back to an initial value.

Is there a way to limit the number of processes, perhaps by using an JVM option?

Best regards and many thanks in advance,
Andreas
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Hi,

Welcome to JavaRanch!

1) "Threads" and "processes" are different things; I can't tell which you mean based on this message. Which is it?

Adding to the confusion, older Linux systems will display each thread as a process in the "ps" listing. Modern ones using the New POSIX Thread Libraru (NPTL) won't do this.

2) This is likely to be a server option, not a JVM option; the JVM won't start threads or processes on its own: it's up to the application running on the JVM, which presumably is either an application server or an ad-hoc application. Which is it? If it's an app server, which one? The answer is very likely to be specific to the particular app server.


[Jess in Action][AskingGoodQuestions]
Andreas Niemeyer
Greenhorn

Joined: Dec 13, 2005
Posts: 4
Thank you for the fast reply and your welcome greetings :-)

Well, I mean processes on OS level and a running application server, which uses sockets in spawned threads to exchange controls and file streamings.

I'm wondering about the remaining huge number of processes if the server idle a while.

Is there an OS option available to change this?

Best regards,
Andreas
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

As I said, the number of thread or processes used is going to be an option of the server software, not of Java itself or of the OS. So what server are you using? Tomcat? JBoss? Weblogic?
Andreas Niemeyer
Greenhorn

Joined: Dec 13, 2005
Posts: 4
Sorry for the missunderstand. No J2EE server mentioned, it is an own developed client-server service for tranferring files.

I found this article here
http://www.unixville.com/~moazam/stories/2004/05/18/debuggingHangsInTheJvm.html

and want now to play around with stackdumps to find the reasons.

I guess some system sockets stays open for listing, for solaris there exists timeout values to close ports (netstat shows some results)

I'll let you know about the progress.
Andreas Niemeyeer
Greenhorn

Joined: Dec 13, 2005
Posts: 2
Hi

I found the bug about sending a `kill -3 ProcID' - dump a stack
trace. The most number of stacks are the same(see below)

A `java.util.zip.ZipInputStream.getNextEntry(Unknown Source)' exception causes a hanging ssl socket though no clients are connected.

A netstat -p shows me a huge number of established connections bounded to the process.

I fixed the code by catching this exception, all works fine now.

Cheers,
Andreas



2. in the ComServerDataThread:
"45" prio=1 tid=0x08367d30 nid=0x13eb runnable [50a79000..50a798b8]
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at com.sun.net.ssl.internal.ssl.InputRecord.a(Unknown Source)
at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(Unknown Source)
- locked <0x44faba20> (a java.lang.Object)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(Unknown Source)
at com.sun.net.ssl.internal.ssl.AppInputStream.read(Unknown Source)
- locked <0x44faba78> (a com.sun.net.ssl.internal.ssl.AppInputStream)
at java.io.FilterInputStream.read(Unknown Source)
at java.io.PushbackInputStream.read(Unknown Source)
at java.util.zip.ZipInputStream.readFully(Unknown Source)
at java.util.zip.ZipInputStream.readLOC(Unknown Source)
at java.util.zip.ZipInputStream.getNextEntry(Unknown Source)
at com.XXX.YYY.prog.thread.ComServerDataThread.receiveData(ComServerDataThread.java:215)
at com.XXX.YYY.prog.thread.ComServerDataThread.run(ComServerDataThread.java:120)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to reduce number of native threads in proc table
 
Similar Threads
Null Pointer Exception
Unable to take heap dump, when exceuting this command(jmap -heap:format=b <process id of jboss>)
Calls trough interface references are slower (on Android)
I have a problem starting my J2EE server
GC alloc all memory of machine