Comments (4)
뷰모델 소스를 보시면 아래와 같이 레퍼런스를 null 로 초기화시켜주고 있고onCleared
메소드는 액티비티의 onDestory
시점에 호출되어 메모리릭이 발생하지 않습니다. (FragmentActivity 소스를 보시면 됩니다)
override fun onCleared() {
coordinator = null // avoid memory leak
}
언급하시것중에 '강한결합'이라는 말은 객체가 의존성의 구현객체를 직접적으로 들고 있을때 사용하는 표현이 아닌가 싶네요. 이를 테면
class Com(val view: View)
class Host(val com: Com) // 강결합
이를 약한결합으로 만들어 보자면
interface Com
class ComImpl(val view: View) : Com
class Host(val com: Com) // 약결합
위의 약결합 예를 보면 Host 입장에서는 com 이 view 를 들고있는지 없는지 알수가 없죠.
from android-mvvm-unittest.
@iam1492 다시 소스를 보고 곰곰히 생각해보니 아래경우에 메모리릭 & 버그가 발생할수 있겠네요.
- 최초 액티비티, 뷰모델 생성
- 사용자가 설정에서 언어변경함
- 액티비티 onDestory 호출
- onDestory 시점에서 설정변경이라 뷰모델의 onCleared 호출안됨
- navigator 의 activity 는 기존꺼 유지
의견 감사합니다. 좀더 고민해서 소스를 수정해보겠습니다.
from android-mvvm-unittest.
7804e50
액티비티의 onDestory
시점에 navigator.activity 를 null 로 초기화하도록 수정했습니다.
from android-mvvm-unittest.
@cchcc 제가 깊이 있게 생각했던건 아니였는데 그래도 릭이 생길 수 있는 부분을 찾으셔서 다행이네요~ 자세한 설명도 감사합니다
from android-mvvm-unittest.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-mvvm-unittest.