title: Room - Query all memory handling
body: <p>I'm considering using the android Room library as a ORM in my app, but i would like to know more details/comments because of some constraints i have and i was not able to find on the internet (ie.Google;))
  When i do the following query:</p>
  
  <pre><code>@Query("SELECT * FROM users")
  List&lt;User&gt; getAll();
  </code></pre>
  
  <p>and if i have thousands off users, wouldn't it be an issue? because from the <strong>generated code below</strong> it seems to load everything into an ArrayList. Event the LiveData> or Flowable> do the same.</p>
  
  <pre><code>@Override
  public List&lt;User&gt; getAll() {
    final String _sql = "SELECT * FROM Users";
    final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0);
    final Cursor _cursor = __db.query(_statement);
    try {
     final int _cursorId = _cursor.getColumnIndexOrThrow("id");
     final int _cursorName = _cursor.getColumnIndexOrThrow("name");
     final List&lt;User&gt; _result = new ArrayList&lt;User&gt;(_cursor.getCount());
     while(_cursor.moveToNext()) {
       final User _item;
       final String _tmpMId;
       _tmpMId = _cursor.getString(_cursorId);
       final String _tmpMName;
       _tmpMName = _cursor.getString(_cursorName);
       _item = new User(_tmpMId,_tmpMName);
       _result.add(_item);
     }
     return _result;
    } finally {
     _cursor.close();
     _statement.release();
    }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>@Override
    public Flowable&lt;List&lt;User&gt;&gt; getAllRX() {
      final String _sql = "SELECT * FROM Users";
      final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0);
      return RxRoom.createFlowable(__db, new String[]{"Users"}, new Callable&lt;List&lt;CachedAttendee&gt;&gt;() {
        public List&lt;User&gt; call() throws Exception {
          final Cursor _cursor = __db.query(_statement);
          try {
            final int _cursorId = _cursor.getColumnIndexOrThrow("id");
            final int _cursorName = _cursor.getColumnIndexOrThrow("name");
            final List&lt;User&gt; _result = new ArrayList&lt;User&gt;(_cursor.getCount());
            while(_cursor.moveToNext()) {
              final User _item;
              final String _tmpMId;
              _tmpMId = _cursor.getString(_cursorId);
              final String _tmpMName;
              _tmpMName = _cursor.getBlob(_cursorName);
              _item = new User(_tmpMId,_tmpMName);
              _result.add(_item);
            }
            return _result;
          } finally {
            _cursor.close();
          }
        }
  
        @Override
        protected void finalize() {
          _statement.release();
        }
      });
    }
  </code></pre>
  
  <p>Am i looking at it wrongly or Google dismissed this point? I can always use Cursors, but that defeats the point of having an ORM handling that serialisation for me.</p>
  
  <p>Cheers,</p>