OSDN Git Service

Fixing parcel leaks to avoid virtual memory leak
authorMaunik Shah <mshah@codeaurora.org>
Thu, 19 Jun 2014 08:48:39 +0000 (14:18 +0530)
committerMaunik Shah <mshah@codeaurora.org>
Thu, 19 Jun 2014 14:14:21 +0000 (19:44 +0530)
Client has to call recycle() on parcel object after its usage
otherwise native layer of binder won't clear the resources of
parcel which were allocated for IPC

Change-Id: Ib31ddcc92aa4ebd80bb66729922b9133692e9c9e

core/java/android/app/ApplicationThreadNative.java
core/java/android/widget/RemoteViews.java

index cb453e2..badaec3 100644 (file)
@@ -1188,6 +1188,7 @@ class ApplicationThreadProxy implements IApplicationThread {
         data.writeInt(level);
         mRemote.transact(SCHEDULE_TRIM_MEMORY_TRANSACTION, data, null,
                 IBinder.FLAG_ONEWAY);
+        data.recycle();
     }
 
     public void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin,
index 0d3df51..b290744 100644 (file)
@@ -1709,7 +1709,9 @@ public class RemoteViews implements Parcelable, Filter {
         Parcel p = Parcel.obtain();
         writeToParcel(p, 0);
         p.setDataPosition(0);
-        return new RemoteViews(p);
+        RemoteViews rv = new RemoteViews(p);
+        p.recycle();
+        return rv;
     }
 
     public String getPackage() {