简体   繁体   中英

In Jelly Bean (Android 4.1) have error occured -> open failed: EMFILE (Too many open files)

I am working on a download application and running multiple thread simultaneously to download fast. But i am facing a problem with android 4.1 jelly bean It producing an exception of Too many files are open (open failed: EMFILE (Too many open files)). as I know , There could be only 1024 file should be open for one process. But issues occurs only with jelly bean not with ICS.

Is There any one can please help to resolve these issues. As it is important to download files in more than 10 thread due to lot's files.

Please suggest any idea. To resolve pro grammatically.

There's a hard limit to the number of open files per process on the linux OS. That number is configurable if you have system level access, but not through Android. There's nothing to do except write your application so fewer files are open at once.

Although realistically, if you're hitting this problem you're probably leaking file handles somewhere. Make sure you close all the files you open- the limit is on open files concurrently, if you close one you can always open a new one to take its place.

I encountered the same problem only in Jellybean a few weeks ago and finally found a workaround. See https://stackoverflow.com/a/20417556/976367

Maybe httpClient "has more bugs" and is deprecated, but this problem with JellyBean is a showstopper. I am using Ksoap2 so I tried all the suggested answers that I could.

  • System.setProperty("http.keepAlive", "false");
  • httpTransportSE.getServiceConnection().setRequestProperty("Connection", "close");
  • httpTransportSE.getServiceConnection().disconnect();

Nothing worked - my solution was to rollback the version of Ksoap2 I'm using from 3.1.1 to 2.6.5. Using 2.6.5 the problem is substantially reduced. Still testing but maybe even solved.

It may be that the reason the older version of KSoap2 works for me is that it's using httpClient rather than httpUrlConnection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM