android – Why Room ORM creates too many dao instances-ThrowExceptions

Exception or error:

I am using Room ORM to cache some data in my application.
when I execute multiple queries, too many DAO instances are created.

this is the code Room uses to provide DAO

public DatabaseDao getDatabaseDao() {
    if (_databaseDao != null) {
      return _databaseDao;
    } else {
      synchronized(this) {
        if(_databaseDao == null) {
          _databaseDao = new DatabaseDao_Impl(this);
        return _databaseDao;

As you can see only one instance of DAO is created

but when I profile the app, I see multiple DatabaseDao_Impl is created.

enter image description here

Is this a problem of Room?

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *