1

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:

  1. StrictMode is implemented into onCreate method of activity A
  2. B activity is started from A
  3. B activity is finished, back to activity A
  4. B activity is started from A
  5. 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?

DroidDroid
  • 11
  • 3

0 Answers0