Skip to content

Commit 3996b41

Browse files
Mattias PeterssonDianne Hackborn
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 69ea4e1 commit 3996b41

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
@@ -9775,6 +9775,7 @@ public void serviceDoneExecutingLocked(ServiceRecord r, boolean inStopping) {
97759775
if (DEBUG_SERVICE) Slog.v(TAG,
97769776
"doneExecuting remove stopping " + r);
97779777
mStoppingServices.remove(r);
9778+
r.bindings.clear();
97789779
}
97799780
updateOomAdjLocked(r.app);
97809781
}

0 commit comments

Comments
 (0)