TOGoS / TMCMR

TOGoS's Minecraft Map Renderer
http://www.nuke24.net/projects/TMCMR/
Other
45 stars 18 forks source link

Immediately close image file after writing it #4

Closed ghost closed 11 years ago

ghost commented 11 years ago

Program crashes while rendering a 2000 radius world (4000 block wide).

java.io.FileNotFoundException: /root/mc/map/tile.-101.56.png (Too many open files)
        at java.io.RandomAccessFile.open(Native Method)
        at java.io.RandomAccessFile.<init>(RandomAccessFile.java:233)
        at javax.imageio.stream.FileImageOutputStream.<init>(FileImageOutputStream.java:69)
        at com.sun.imageio.spi.FileImageOutputStreamSpi.createOutputStreamInstance(FileImageOutputStreamSpi.java:55)
        at javax.imageio.ImageIO.createImageOutputStream(ImageIO.java:419)
        at javax.imageio.ImageIO.write(ImageIO.java:1530)
        at togos.minecraft.maprend.RegionRenderer.renderAll(RegionRenderer.java:227)
        at togos.minecraft.maprend.RegionRenderer.main(RegionRenderer.java:339)
ghost commented 11 years ago

Related: http://stackoverflow.com/questions/10441276/jdk-1-7-too-many-open-files-due-to-posix-semaphores

TOGoS commented 11 years ago

Updated to close RegionFiles in e11e93bf88d67bb2c33b0c78357e64b100ea8da5.

TOGoS commented 11 years ago

Was ImageIO.write( RenderedImage, String, File ) failing to close output files after use? I'd rather leave that part as-is if it was just unclosed RegionFiles eating up all the filehandles.

ghost commented 11 years ago

I believe it was only RegionFiles (RandomAccessFile) which needed to be closed.

TOGoS commented 11 years ago

Then this should be fixed! Thanks for finding the bug.