igding / CodeReview

代码规范
0 stars 0 forks source link

内存泄漏 #1

Open liushenen opened 4 years ago

liushenen commented 4 years ago

https://github.com/igding/CodeReview/blob/a8aa6e538c6926112038cb9185411a17665a68ef/app/src/main/java/com/baidu/codereview/activity/SplashActivity.java#L42 https://github.com/igding/CodeReview/blob/a8aa6e538c6926112038cb9185411a17665a68ef/app/src/main/java/com/baidu/codereview/activity/SplashActivity.java#L82

异步post的任务,此时如果按返回键退出会造成Activity内存泄漏。

liushenen commented 4 years ago

https://github.com/igding/CodeReview/blob/a8aa6e538c6926112038cb9185411a17665a68ef/app/src/main/java/com/baidu/codereview/activity/SplashActivity.java#L68

异步请求回来后Activity可能已经销毁了,如果这里传入activity会造成内存泄漏。原因是Callback会持有Activity的引用。造成循环引用。