title: Realm - consuming battery in background
body: <p>I change my Android project to use Realm recently.
  But when it runs at some devices, it consumes battery a lot.
  My user report an issue, that is, when my application is in the background, the CPU rate will raise up to 100% occasionally and drains battery to zero.
  It's not happened in the previous version of my application which didn't include Realm.
  But I can't reproduce this problem on my test device or emulator.
  So I can't get the method tracing.</p>
  
  <p>Here's the device information:</p>
  
  <blockquote>
    <p>Asus PadFone 2 (A68) Android 4.4 with 2G RAM</p>
  </blockquote>
  
  <p>And the user's device is rooted by this apk:<a href="http://root.360.cn/" rel="nofollow">http://root.360.cn/</a></p>
  
  <p>I've asked the user to monitor the files which Realm created to see if it's updated frequently.
  But no, it's not updated after my application is in background.
  And the database file grew up correctly, so the data should already been stored.</p>
  
  <p>And here's the codes how I initialize Realm:</p>
  
  <pre><code>Realm.init(this);
  RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
                  .schemaVersion( REALM_DATABASE_VERSION ) // Must be bumped when the schema changes
                  .migration( migration ) // Migration to run instead of throwing an exception
  //                .deleteRealmIfMigrationNeeded()
                  .build();
  
  Realm.compactRealm( realmConfiguration );
  Realm.setDefaultConfiguration(realmConfiguration);
  </code></pre>