NIO CPU Anomaly

Discussion in 'Java' started by JSParker1@hotmail.co.uk, Dec 14, 2004.

Guest

I have recently run into an anomaly using the NIO packages in a
multithread thick client. Can anybody help?
The app opens a few of IP connection (about 20) for two way
communication. It was recently migrated across to use the NIO API and
this has caused the client CPU to hit 100% even when idle. On the old
IO packages this was <1% CPU.
(This is my first newsgroup posting so please let me know if I should
include more/less info).

Advertisements

On 14 Dec 2004 03:35:29 -0800, wrote:
> I have recently run into an anomaly using the NIO packages in a
> multithread thick client. Can anybody help?
>
> The app opens a few of IP connection (about 20) for two way
> communication. It was recently migrated across to use the NIO API
> and this has caused the client CPU to hit 100% even when idle. On
> the old IO packages this was <1% CPU.
>
> (This is my first newsgroup posting so please let me know if I should
> include more/less info).

Well, generally you should post a relevant section of code, ideally
something short that compiles and has the problem you describe.

However I suspect that you need to remove the SelectionKey from the
selection Set, or select() will immediately return the same key again
(even though it might not be ready). Something like this:

Advertisements

On 14 Dec 2004 22:41:28 +0100, Gordon Beaton <> wrote:
> Well, generally you should post a relevant section of code, ideally
> something short that compiles and has the problem you describe.
>
> However I suspect that you need to remove the SelectionKey from the
> selection Set, or select() will immediately return the same key again
> (even though it might not be ready). Something like this:
> /gordon

Another thing that comes to mind is that you might have switched some
Channel to non-blocking IO, and read it as if it was blocking, which
results in hundreds of read-calls all returning no new data.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!