You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have an Android app which uses RxJava and has a Background Service; The background service process uses RxJava also.
Some of our users report an impact on battery life during idle periods (e.g. overnight) even though our background service has no work to do.
I did some profiling, and discovered RxJava creates two instances of the ObjectPool class, for pooling instances of SpscArrayQueue and SpmcArrayQueue. These appear to be used indirectly by the Merge and Zip observable operators.
The ObjectPool class internally creates a recurring timer which runs every 67 seconds persistently. This timer runs regardless of whether there is any work to do, and it shows up under profiling. We believe this may be the cause of battery life drain overnight, as every 67 seconds the phone must wake up.
Note however, that there are other periodic timers such as io() scheduler cleanup (every minute) and thread-pool purging on a Java 6 runtime (every second).
I'm preparing a PR that removes ObjectPool and add documentation to Schedulers about which system parameter to change for the latter two.
We have an Android app which uses RxJava and has a Background Service; The background service process uses RxJava also.
Some of our users report an impact on battery life during idle periods (e.g. overnight) even though our background service has no work to do.
I did some profiling, and discovered RxJava creates two instances of the ObjectPool class, for pooling instances of SpscArrayQueue and SpmcArrayQueue. These appear to be used indirectly by the Merge and Zip observable operators.
The ObjectPool class internally creates a recurring timer which runs every 67 seconds persistently. This timer runs regardless of whether there is any work to do, and it shows up under profiling. We believe this may be the cause of battery life drain overnight, as every 67 seconds the phone must wake up.
Refer to line 113 of ObjectPool.java
RxJava/src/main/java/rx/internal/util/ObjectPool.java
Line 113 in 010256b
It would seem more prudent to only start this timer when the pool is accessed, and stop the timer if the pool is not being used.
I hope to have a pull request ready in a few days
The text was updated successfully, but these errors were encountered: