Mp4InfoReader and Mp4TagReader leave open FileChannels

Issue #337 resolved
Dan Gravell created an issue

Calling the read methods in Mp4InfoReader and Mp4TagReader open a ByteChannel but the channel is not subsequently closed.

On Linux, over time this builds up the number of file handles. This can be seen by using lsof -p <pid>. Eventually the process runs out of its maximum allocation of file handles and the OS refuses to perform any more file operations.

For other file types, we can see the file is closed after reading. FlacInfoReader opens a FileChannel in a try-with-resources block, so the channel is closed after the block is completed. MP3File uses RandomAccessFile, but the raf is closed in a finally block after being read.

Therefore I propose reading MP4s works the same as the FLAC readers - the channel is closed by a try-with-resources block.

See https://bitbucket.org/ijabz/jaudiotagger/pull-requests/66/

Comments (3)

  1. Log in to comment