LeakCanary参考:https://github.com/square/leakcanary/wiki/FAQ#how-does-it-work https://blog.csdn.net/xinzhou201/article/details/78637700 GitHub上关于LeakCanary的原理: RefWatcher.watch() creates a KeyedWeakReference to the watched object. Later, in a ...
SharedPreferences中commit与apply的区别
SharedPreferences中commit与apply的区别 apply()写入文件的操作是异步的,会把Runnable放到线程池中执行,而commit()的写入文件的操作是在当前线程同步执行的。 因此当两者都可以使用的时候还是推荐使用apply(),因为apply()写入文件操作是异步执行的,不会占用主线程资源。 commit()有返回值,apply()没有返回值。apply()失败了是不会报错的。 另外: 1、如果先后apply()了几次,那么会以最后一次apply()的为准。...