Finding Memory Leaks
Kotlin is a JVM-based language that has a garbage collector, which is a daemon thread that runs on the JVM and is responsible for automatic memory management. This reclaims the memory allocated to objects that are no longer referenced by the program running inside the VM. We will discuss more about garbage collector later in the chapter.
In execution, a program creates the objects required for the computation. Here, the memory is allocated for objects in the heap region. Once the program has finished using these objects, they are no longer needed by the program and it holds no reference to the objects that it has created. An object is garbage collected when it is no longer referenced by the program. A memory leak occurs ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access