Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 53195e0d authored by Tony Mak's avatar Tony Mak
Browse files

Fix memory leak in TCMS when TCSession.destroy() is not called.

TCMS stores sessions in a Map and remove it when the session is
destroyed. Memory leak happens if the client forget to call
TCSession.destroy() or does not have a chance to call before the process
is dead.

Solution:
1. Use linkToDeath() to remove the cached session when client process
   is dead. TCSessionID now contains a binder to make this possible.
2. Install a Cleaner to TCSession object such that destroy() is called
   whenever the session object is going to be GCed. This is needed
   because some clients may have a long lifecycle, e.g. apps that are
   bounded by system.

BUG:149012454

Test: Write an app that creates a TC session, but not calling destory().
      Then make sure TCMS removed the session in the following situations:
      1. The app is killed
      2. TCSession object is GCed (By forcing GC)
      By checking the output dumpsys textclassificataion, we can know
      that the session object is removed
Test: mts-tradefed run mts-extservices
Test: Sanity test: smart selection + smart replies

Change-Id: Ifb7dcb23e1f50d4b3e97a6ce40e63b57193f2892
parent 2cfc5bb1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment