Skip to content

Commit 5f619b7

Browse files
Mattias PeterssonJohan Redestig
authored andcommitted
Avoiding cyclic references when unbinding from a service
Cyclic references can occur between a Service object held by an application and a ServiceRecord object held by the system server. A part of the problem is that binders are leaked and since many binders are implemented by inner classes of services these services are also leaked. This causes low memory problems. The solution is: When a Service is beeing destroyed, go through the ServiceRecord's all IntentBindRecord and set its binder references to null. This allows the binder and the service object to be garbage collected. Change-Id: I5a257521964851f34c08ffb3908feaad96b1bafe
1 parent 3769240 commit 5f619b7

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

services/java/com/android/server/am/ActivityManagerService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9802,6 +9802,7 @@ public void serviceDoneExecutingLocked(ServiceRecord r, boolean inStopping) {
98029802
if (DEBUG_SERVICE) Slog.v(TAG,
98039803
"doneExecuting remove stopping " + r);
98049804
mStoppingServices.remove(r);
9805+
r.bindings.clear();
98059806
}
98069807
updateOomAdjLocked(r.app);
98079808
}

0 commit comments

Comments
 (0)