patrickyin / clean-architecture-android-kotlin

Using Uncle Bob's clean architecture with Kotlin language and the latest Android technologies(Rx, Dagger2 etc.).
Apache License 2.0
330 stars 45 forks source link

Memory leak #8

Open anhduy5689h opened 5 years ago

anhduy5689h commented 5 years ago

Because your modules didn't support custom scopes so memory leak is existing Example: class GetArticlesListUseCase @Inject constructor(private val articlesRepository: ArticlesRepository, subscribeScheduler: Scheduler, postExecutionScheduler: Scheduler) : UseCase<List

, Unit>(subscribeScheduler, postExecutionScheduler) {

override fun buildUseCaseSingle(params: Unit?): Single<List

> = articlesRepository.articles() .map { it.map { Article(it.title, it.pubDate, it.link) } } //I added some code at here to check memory leak by Profiler of Android Studio var test: ByteArray? = null init { test = ByteArray(1024102450) }

fun test() {
    if (test != null) {

    }
}

}

//Java memory in MEMORY tab from Profiler increases 50KB->100KB->150KB... whenever the app opens the activity which is using GetArticlesListUseCase

paduy commented 5 years ago

I updated some code to fix this issue. You can review my code at below link https://github.com/nghephamvan/android_clean_architecture/tree/dev_duy