title: Firebase DB: Application has opened too many files. Maximum of available file descriptors in one process is 1024 in default
body: <p>I'm getting the following error in Firebase. My code doesn't open any files directly, but it works extensively with HttpOK, WebRTC and overall networking. Does networking also using file descriptors? Since the error is not raised by my code, I'm curious how I can fix it. Can I see somehow where and which file descriptors open? (then I can find what causes the descriptors leaks).</p>
  <blockquote>
  <p>2021-06-13 04:14:59.610 30892-30994/com.mafialab.mafia
  E/SQLiteDatabase: Failed to open database
  '/data/user/0/com.mafialab.mafia/databases/google_app_measurement_local.db'.
  android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 2062): Could not open database
  #################################################################
  Error Code : 2062 (SQLITE_CANTOPEN_EMFILE)
  Caused By : Application has opened too many files. Maximum of available file descriptors in one process is 1024 in default.
  (unknown error (code 2062): Could not open database)
  #################################################################
  at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
  at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:262)
  at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:205)
  at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:649)
  at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:255)
  at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:222)
  at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:1191)
  at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:1146)
  at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:861)
  at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:729)
  at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:310)
  at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:254)
  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:194)
  at com.google.android.gms.measurement.internal.zzef.getWritableDatabase(com.google.android.gms:play-services-measurement-impl@@19.0.0:1)
  at com.google.android.gms.measurement.internal.zzeg.zzo(com.google.android.gms:play-services-measurement-impl@@19.0.0:1)
  at com.google.android.gms.measurement.internal.zzeg.zzq(com.google.android.gms:play-services-measurement-impl@@19.0.0:6)
  at com.google.android.gms.measurement.internal.zzeg.zzi(com.google.android.gms:play-services-measurement-impl@@19.0.0:9)
  at com.google.android.gms.measurement.internal.zzjk.zzl(com.google.android.gms:play-services-measurement-impl@@19.0.0:6)
  at com.google.android.gms.measurement.internal.zzhw.zzu(com.google.android.gms:play-services-measurement-impl@@19.0.0:147)
  at com.google.android.gms.measurement.internal.zzhc.run(com.google.android.gms:play-services-measurement-impl@@19.0.0:1)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at com.google.android.gms.measurement.internal.zzfq.run(com.google.android.gms:play-services-measurement-impl@@19.0.0:6)
  2021-06-13 04:14:59.619 30892-30994/com.mafialab.mafia E/FA: Opening
  the local database failed, dropping and recreating it 2021-06-13
  04:14:59.622 30892-30994/com.mafialab.mafia W/SQLiteLog: (28) failed
  to open
  &quot;/data/user/0/com.mafialab.mafia/databases/google_app_measurement_local.db&quot;
  with flag (131138) and mode_t (0) due to error (24) 2021-06-13
  04:14:59.622 30892-30994/com.mafialab.mafia W/SQLiteLog: (28) failed
  to open
  &quot;/data/user/0/com.mafialab.mafia/databases/google_app_measurement_local.db&quot;
  with flag (131072) and mode_t (0) due to error (24) 2021-06-13
  04:14:59.622 30892-30994/com.mafialab.mafia E/SQLiteLog: (14) cannot
  open file at line 36170 of [4bb21d8205] 2021-06-13 04:14:59.622
  30892-30994/com.mafialab.mafia E/SQLiteLog: (14) os_unix.c:36170: (24)
  open(/data/user/0/com.mafialab.mafia/databases/google_app_measurement_local.db)</p>
  <ul>
  <li>2021-06-13 04:14:59.622 30892-30994/com.mafialab.mafia E/SQLiteLog: (1) Process  : Pid (30892) Uid (10190) Euid (10190) Gid (10190) Egid
  (10190) 2021-06-13 04:14:59.624 30892-30994/com.mafialab.mafia
  E/SQLiteDatabase: Failed to open database
  '/data/user/0/com.mafialab.mafia/databases/google_app_measurement_local.db'.
  android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 2062): Could not open database
  #################################################################
  Error Code : 2062 (SQLITE_CANTOPEN_EMFILE)
  Caused By : Application has opened too many files. Maximum of available file descriptors in one process is 1024 in default.
  (unknown error (code 2062): Could not open database)
  #################################################################
  at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
  at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:262)
  at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:205)
  at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:649)
  at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:255)
  at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:222)
  at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:1191)
  at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:1146)
  at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:861)
  at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:729)
  at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:310)
  at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:254)
  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:194)
  at com.google.android.gms.measurement.internal.zzef.getWritableDatabase(com.google.android.gms:play-services-measurement-impl@@19.0.0:9)
  at com.google.android.gms.measurement.internal.zzeg.zzo(com.google.android.gms:play-services-measurement-impl@@19.0.0:1)
  at com.google.android.gms.measurement.internal.zzeg.zzq(com.google.android.gms:play-services-measurement-impl@@19.0.0:6)
  at com.google.android.gms.measurement.internal.zzeg.zzi(com.google.android.gms:play-services-measurement-impl@@19.0.0:9)
  at com.google.android.gms.measurement.internal.zzjk.zzl(com.google.android.gms:play-services-measurement-impl@@19.0.0:6)
  at com.google.android.gms.measurement.internal.zzhw.zzu(com.google.android.gms:play-services-measurement-impl@@19.0.0:147)
  at com.google.android.gms.measurement.internal.zzhc.run(com.google.android.gms:play-services-measurement-impl@@19.0.0:1)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at com.google.android.gms.measurement.internal.zzfq.run(com.google.android.gms:play-services-measurement-impl@@19.0.0:6)
  2021-06-13 04:14:59.625 30892-30994/com.mafialab.mafia E/FA: Failed to
  open local database. Events will bypass local storage:
  android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error
  (code 2062): Could not open database
  #################################################################
  Error Code : 2062 (SQLITE_CANTOPEN_EMFILE)
  Caused By : Application has opened too many files. Maximum of available file descriptors in one process is 1024 in default.
  (unknown error (code 2062): Could not open database)
  #################################################################: com.google.android.gms.measurement.internal.zzef.getWritableDatabase(com.google.android.gms:play-services-measurement-impl@@19.0.0:9)</li>
  </ul>
  </blockquote>