rossturner / king-under-the-mountain

A simulation-based strategy game written in Java using LibGDX
MIT License
106 stars 17 forks source link

java.io.IOException: Too many open files #19

Closed neoedmund closed 3 months ago

neoedmund commented 3 months ago

I tried to compile and run the app on linux, but get Too many open files when packageModsToAssets I guess the dev use Windows not knowing the issue. I use lsof to find out all 4000+ opened files are all DIR is the 'core/mods/base' So what the meaning of opened Directory in java? why Directory even need to be "open"? What operation did that? Thanks, any help ?

neoedmund commented 3 months ago

Well , I figure out myself. There are serveral places using java.nio.file.Files.list() especially the one in ArtifactParser.java as JDK javadoc said: "This method must be used within a try-with-resources statement or similar control structure to ensure that the stream's open directory is closed promptly after the stream's operations have completed." And misuse made the resource leak. After fix that, I'm able to run the app. But I have a bad feeling because the CPU usage is so high(on intel intergrated gpu, okay on others)