tags:

views:

14

answers:

1

I have been working with dnsjava to do a lot of DNS lookups, using the Lookup class with its own resolver per lookup, and also with a single shared resolver. No matter how I invoke it, there are always collections of sockets left open at the end of the process, and eventually my process runs out of file descriptors and is killed.

Tracing the code, I found that creating a Selector object causes two additional sockets to be created, and these are the two that are never closed. The dnsjava code is calling the Selector's close() method (I have stepped over that and verified that the two sockets, sink and source, are left open after it).

Has anybody else seen this? Is there some way I can force those sockets to close? I don't see any public API to get the source and sink socket references from the Selector class, but perhaps I am missing something?

A: 

this is a known [fixed] bug: http://code.google.com/p/android/issues/detail?id=4825

relatedly, i've rewritten Pipe to not use sockets at all: http://code.google.com/p/android/issues/detail?id=9431

sadly, i'm not aware of a workaround. (unless you want to use reflection.)

Elliott Hughes