Answer the question
In order to leave comments, you need to log in
Memory leak, objects are not deleted?
After creating the database, I check if the objects are deleted, and they are not deleted, all the functions in Dao hang in the profiler, 11 objects are not deleted, even when I closed the database in onStop, nothing changed when I assigned null to all variables, nothing has changed, as 11 objects hung, they hang, I created a new application, and wrote
var context:Context? = null
context= this.applicationContext
class MainActivity : AppCompatActivity(),View.OnClickListener {
var context:Context? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
context= this.applicationContext
button.setOnClickListener(this)
val a = Test()
val a2 = Test()
a.a=4
a2.b=5
}
override fun onClick(v: View?) {
startActivity(Intent(this,MainActivity2::class.java))
}
}
Answer the question
In order to leave comments, you need to log in
To begin with, check correctly if there is a leak. References should not remain after the garbage collector has finished. What and how to do to search for memory leaks is very well described in this article:
https://habr.com/ru/company/sebbia/blog/243537/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question