Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Strict mode violations #28

Merged
merged 1 commit into from
May 12, 2015
Merged

Fix Strict mode violations #28

merged 1 commit into from
May 12, 2015

Conversation

pyricau
Copy link
Member

@pyricau pyricau commented May 10, 2015

  • Enable Strict Mode thread policy in the sample app.
  • Fixed violation when cleaning up files on startup.
  • Fixed violation when enabling components, the other side of the binder does IO operations.

Fixes #15

.penaltyDeath() //
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() //
.detectAll() //
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to note is that this detectAll() call enables some Activity reference counting. In my experience it gives quite a few false positives: http://stackoverflow.com/questions/21145261/strictmode-activity-instance-count-violation-2-instances-1-expected-on-rotati

Since LeakCanary monitors Activity leaks already, I've modified my StrictMode setup to manually enable everything except for the Activity counting:

StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
        .detectLeakedClosableObjects()
        .detectLeakedRegistrationObjects()
        .detectLeakedSqlLiteObjects()
        .penaltyLog()
        .penaltyDeath()
        .build());

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent point. I actually looked at Strict mode when I started working on LeakCanary, I liked the idea but hated the implementation.

* Enable Strict Mode thread policy in the sample app.
* Fixed violation when cleaning up files on startup.
* Fixed violation when enabling components, the other side of the binder does IO operations.

Fixes #15
pyricau added a commit that referenced this pull request May 12, 2015
Fix Strict mode violations. Fixes #15.
@pyricau pyricau merged commit c8f9e19 into master May 12, 2015
@pyricau pyricau deleted the py/strict_mode branch May 12, 2015 16:23
Yky pushed a commit to Yky/leakcanary that referenced this pull request Feb 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StrictMode disk access violation
2 participants