EVALUATION
This fix reports a leak of file handlers on macosx. It mentioned two ways to leak handlers:
via ImageIO.read(ImageInputStream), and via semaphores.
I do not observe the first leak: we explicitly close input stream if we found an appropriate reader,
and this is enough (at least on 1.7.4) to release file handles.
However, in case of semaphores we leak tons of handles: we perform color conversion
for each line of jpeg image, and each time we create a semaphore (because we see 2 or more
CPU installed on the system), then we reduce number of separate tasks down to 1 (because
we have single scan line to process) and due to this never unlink the semaphore.
The same problem is present on Linux systems, but in less degree because we occupy single
file handle per named semaphore, whereas on macosx we always occupy new file handle.
Suggested fix just postpones the creation of named semaphore until we clarify the number of
separate tasks, so, now we do not create semaphores for image reading and simple color
conversions (like ColorSpace.toRGB()). Beside this, now we use pSem pointer as a trigger
for the semaphore destruction.
|