boB Gage wrote:
Hi again...
I am working on an application that has to discover serial devices
from a large set of known devices (each represented by their own
collection of ProtocolHandler, CodecFactory, Encoders, and Decoders).
In the process of doing this, I am running through a list of known
protocols, for each I:
Create an IoConnector and a SerialAddress
Attempt to connect -- which eventually fails because this is the
wrong protocol
Cycle to the next & try it...
Eventually (assuming it's there to be found) the right combination is
attempted and all is good.
BUT.... turn off that device (or attach something that doesn't match
any of the known protocols) and you can see an unbound thread growth.
Each cycle through the discovery process above generates several
(six-ish) threads, most of which die. Two don't, and remain in a
WAITING state forevermore.
According to JProfiler, they are:
SerialConnector-#-idleStatusChecker created from
org.apache.mina.transport.serial.SerialConnector.<init>()
and
Thread-# created from
org.apache.mina.core.session.IoSession.write(java.lang.Object)
The various numbers in the Thread-# names increment by 4 in the
threads that are left behind after each cycle (ie 4 get created, 3 die
-- the same 3 by creation order) -- The SerialConnector numbers
increment by one. (ie. none of the idleStatusChecker threads ever goes
away)
So far I have seen no bound in the thread creation.
In the execution I am currently profilling, my baseline was way back
at time =0:50 with a thread count of 10. I'm now at time=243:33 with
a thread count of 463.
Any clues would be greatly appreciated!!!
Hi boB,
sorry for the latency...
Why are you trying to connect each time to test the protocol for the
device ? You should be able to connect only once, and deal with the
different protocols in the Codec filter, switching from one codec to the
other until you get the right one, or ended without any match.
Doing so, you should be able to avoid creating useless connectors...
--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org