I have implemented StrictMode in my app with these options:
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectNetwork()
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectActivityLeaks()
.penaltyLog()
.penaltyDeath()
.build());
Application has two activities (A and B) and the scenario is:
- StrictMode is implemented into onCreate method of activity A
- B activity is started from A
- B activity is finished, back to activity A
- B activity is started from A
- B activity is finished, A activity is killed by StrictMode (penaltyDeath)
When activity A is killed I receive a message:
class AActivity; instances=2; limit=1 android.os.StrictMode$InstanceCountViolation: class AActivity; instances=2; limit=1 at android.os.StrictMode.setClassInstanceLimit(StrictMode.java:1)
Activity B is started via custom button (it has only empty constructors, the same like B activity). I tried to set class instance limit in StrictMode but without result. Curious thing is that without penaltyDeath() option the number of activity instances raise up to 15-17 and then GC is coming.
Someone has similar problem with StrictMode?