Fix memory leaks in system_server

unlink DeathRecipients in a whole bunch of places to avoid memory leaks
This commit is contained in:
Suchi Amalapurapu
2009-06-30 21:36:16 -07:00
parent c56096fe1f
commit fff2fda019
8 changed files with 41 additions and 6 deletions

View File

@@ -507,6 +507,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
private void removeProvider(LocationProviderProxy provider) {
mProviders.remove(provider);
provider.unlinkProvider();
mProvidersByName.remove(provider.getName());
}

View File

@@ -709,7 +709,10 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage
p.awakeOnSet = true;
}
} else {
mPokeLocks.remove(token);
PokeLock rLock = mPokeLocks.remove(token);
if (rLock != null) {
token.unlinkToDeath(rLock, 0);
}
}
int oldPokey = mPokey;

View File

@@ -1875,7 +1875,9 @@ public class WifiService extends IWifiManager.Stub {
private WifiLock removeLock(IBinder binder) {
int index = findLockByBinder(binder);
if (index >= 0) {
return mList.remove(index);
WifiLock ret = mList.remove(index);
ret.unlinkDeathRecipient();
return ret;
} else {
return null;
}
@@ -1987,6 +1989,10 @@ public class WifiService extends IWifiManager.Stub {
binderDied();
}
}
void unlinkDeathRecipient() {
mBinder.unlinkToDeath(this, 0);
}
}
private class Multicaster extends DeathRecipient {
@@ -2054,7 +2060,10 @@ public class WifiService extends IWifiManager.Stub {
private void removeMulticasterLocked(int i, int uid)
{
mMulticasters.remove(i);
Multicaster removed = mMulticasters.remove(i);
if (removed != null) {
removed.unlinkDeathRecipient();
}
if (mMulticasters.size() == 0) {
WifiNative.startPacketFiltering();
}

View File

@@ -3407,7 +3407,10 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
synchronized (mWindowMap) {
for (int i=0; i<mRotationWatchers.size(); i++) {
if (watcherBinder == mRotationWatchers.get(i).asBinder()) {
mRotationWatchers.remove(i);
IRotationWatcher removed = mRotationWatchers.remove(i);
if (removed != null) {
removed.asBinder().unlinkToDeath(this, 0);
}
i--;
}
}
@@ -5442,6 +5445,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
} catch (RemoteException e) {
}
synchronized(mWindowMap) {
mClient.asBinder().unlinkToDeath(this, 0);
mClientDead = true;
killSessionLocked();
}

View File

@@ -119,6 +119,7 @@ public class StatusBarService extends IStatusBar.Stub
public void binderDied() {
Log.i(TAG, "binder died for pkg=" + pkg);
disable(0, token, pkg);
token.unlinkToDeath(this, 0);
}
}
@@ -494,6 +495,7 @@ public class StatusBarService extends IStatusBar.Stub
if (what == 0 || !token.isBinderAlive()) {
if (tok != null) {
mDisableRecords.remove(i);
tok.token.unlinkToDeath(tok, 0);
}
} else {
if (tok == null) {