{"action":"created","issue":{"url":"https://api.github.com/repos/biojava/biojava/issues/395","labels_url":"https://api.github.com/repos/biojava/biojava/issues/395/labels{/name}","comments_url":"https://api.github.com/repos/biojava/biojava/issues/395/comments","events_url":"https://api.github.com/repos/biojava/biojava/issues/395/events","html_url":"https://github.com/biojava/biojava/issues/395","id":130359031,"number":395,"title":"Exception when too many files requested to AtomCache","user":{"login":"lafita","id":11161522,"avatar_url":"https://avatars.githubusercontent.com/u/11161522?v=3","gravatar_id":"","url":"https://api.github.com/users/lafita","html_url":"https://github.com/lafita","followers_url":"https://api.github.com/users/lafita/followers","following_url":"https://api.github.com/users/lafita/following{/other_user}","gists_url":"https://api.github.com/users/lafita/gists{/gist_id}","starred_url":"https://api.github.com/users/lafita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lafita/subscriptions","organizations_url":"https://api.github.com/users/lafita/orgs","repos_url":"https://api.github.com/users/lafita/repos","events_url":"https://api.github.com/users/lafita/events{/privacy}","received_events_url":"https://api.github.com/users/lafita/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/biojava/biojava/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-01T13:11:45Z","updated_at":"2016-02-01T17:32:34Z","closed_at":null,"body":"When the same **AtomCache** is used to request for many structures (not at the same time) an Exception is thrown and the following message is given: **Too many open files**. \r\n\r\nIt could indicate a resource or memory leak in **AtomCache**, by maintaining some files open (although the structure has already been downloaded). I get those Exceptions when downloading, in parallel 4 at the same time, more than 2K structures. I do not remember the Exception when I calculated the census the first time (6 months ago), although I am not sure if I was using exactly the same code. Any ideas?\r\n\r\nThis is the **stacktrace** of the Exception:\r\n\r\n```java\r\njava.io.FileNotFoundException: /scratch/cache/data/structures/divided/mmCIF/rl/1rlr.cif.gz (Too many open files)\r\n\tat java.io.FileInputStream.open(Native Method) ~[?:1.6.0_38]\r\n\tat java.io.FileInputStream.<init>(FileInputStream.java:140) ~[?:1.6.0_38]\r\n\tat org.biojava.nbio.core.util.FlatFileCache.addToCache(FlatFileCache.java:63) [classes/:?]\r\n\tat org.biojava.nbio.core.util.InputStreamProvider.getInputStreamFromFile(InputStreamProvider.java:247) [classes/:?]\r\n\tat org.biojava.nbio.core.util.InputStreamProvider.getInputStream(InputStreamProvider.java:163) [classes/:?]\r\n\tat org.biojava.nbio.structure.io.LocalPDBDirectory.getInputStream(LocalPDBDirectory.java:377) [classes/:?]\r\n\tat org.biojava.nbio.structure.io.LocalPDBDirectory.getStructureById(LocalPDBDirectory.java:343) [classes/:?]\r\n\tat org.biojava.nbio.structure.align.util.AtomCache.loadStructureFromCifByPdbId(AtomCache.java:1038) [classes/:?]\r\n\tat org.biojava.nbio.structure.align.util.AtomCache.getStructureForPdbId(AtomCache.java:1019) [classes/:?]\r\n\tat org.biojava.nbio.structure.scop.ScopDomain.loadStructure(ScopDomain.java:245) [classes/:?]\r\n\tat org.biojava.nbio.structure.align.client.StructureName.loadStructure(StructureName.java:349) [classes/:?]\r\n\tat org.biojava.nbio.structure.align.util.AtomCache.getStructure(AtomCache.java:394) [classes/:?]\r\n\tat demo.CeSymmMain$CeSymmWorker.run(CeSymmMain.java:1061) [classes/:?]\r\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [?:1.6.0_38]\r\n\tat java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [?:1.6.0_38]\r\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:166) [?:1.6.0_38]\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146) [?:1.6.0_38]\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.6.0_38]\r\n\tat java.lang.Thread.run(Thread.java:701) [?:1.6.0_38]\r\n``"},"comment":{"url":"https://api.github.com/repos/biojava/biojava/issues/comments/178086921","html_url":"https://github.com/biojava/biojava/issues/395#issuecomment-178086921","issue_url":"https://api.github.com/repos/biojava/biojava/issues/395","id":178086921,"user":{"login":"josemduarte","id":6000474,"avatar_url":"https://avatars.githubusercontent.com/u/6000474?v=3","gravatar_id":"","url":"https://api.github.com/users/josemduarte","html_url":"https://github.com/josemduarte","followers_url":"https://api.github.com/users/josemduarte/followers","following_url":"https://api.github.com/users/josemduarte/following{/other_user}","gists_url":"https://api.github.com/users/josemduarte/gists{/gist_id}","starred_url":"https://api.github.com/users/josemduarte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josemduarte/subscriptions","organizations_url":"https://api.github.com/users/josemduarte/orgs","repos_url":"https://api.github.com/users/josemduarte/repos","events_url":"https://api.github.com/users/josemduarte/events{/privacy}","received_events_url":"https://api.github.com/users/josemduarte/received_events","type":"User","site_admin":false},"created_at":"2016-02-01T17:32:34Z","updated_at":"2016-02-01T17:32:34Z","body":"The first stack trace you post is for a file not found, that doesn't look like a problem with too many open files. The second one does.\r\n\r\nThis reminds me of an issue fixed recently, where we had a resource leak with `DownloadChemCompProvider` (see commit d3bb20e2369).  I suppose you are running on latest HEAD, aren't you?"}}