diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 6493e97..560c3c7 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -96,6 +96,25 @@
         doInBackgroundCallback = bgR;
         postExecuteCallback = postR;
     }
+    void cleanup(boolean cancelled) {
+        // Clean up any references to source/generated bitmaps
+        if (sourceImages != null) {
+            if (cancelled) {
+                for (Bitmap b : sourceImages) {
+                    b.recycle();
+                }
+            }
+            sourceImages.clear();
+        }
+        if (generatedImages != null) {
+            if (cancelled) {
+                for (Bitmap b : generatedImages) {
+                    b.recycle();
+                }
+            }
+            generatedImages.clear();
+        }
+    }
     int page;
     ArrayList<Object> items;
     ArrayList<Bitmap> sourceImages;
@@ -746,21 +765,31 @@
                 @Override
                 public void run(AppsCustomizeAsyncTask task, AsyncTaskPageData data) {
                     try {
-                        Thread.sleep(sleepMs);
-                    } catch (Exception e) {}
-                    loadWidgetPreviewsInBackground(task, data);
+                        try {
+                            Thread.sleep(sleepMs);
+                        } catch (Exception e) {}
+                        loadWidgetPreviewsInBackground(task, data);
+                    } finally {
+                        if (task.isCancelled()) {
+                            data.cleanup(true);
+                        }
+                    }
                 }
             },
             new AsyncTaskCallback() {
                 @Override
                 public void run(AppsCustomizeAsyncTask task, AsyncTaskPageData data) {
-                    mRunningTasks.remove(task);
-                    if (task.isCancelled()) return;
-                    if (task.page > getPageCount()) return;
-                    if (task.pageContentType != mContentType) return;
-                    onSyncWidgetPageItems(data);
+                    try {
+                        mRunningTasks.remove(task);
+                        if (task.isCancelled()) return;
+                        if (task.page > getPageCount()) return;
+                        if (task.pageContentType != mContentType) return;
+                        onSyncWidgetPageItems(data);
+                    } finally {
+                        data.cleanup(task.isCancelled());
+                    }
                 }
-        });
+            });
 
         // Ensure that the task is appropriately prioritized and runs in parallel
         AppsCustomizeAsyncTask t = new AppsCustomizeAsyncTask(page, mContentType,
@@ -790,40 +819,50 @@
             new AsyncTaskCallback() {
                 @Override
                 public void run(AppsCustomizeAsyncTask task, AsyncTaskPageData data) {
-                    // Ensure that this task starts running at the correct priority
-                    task.syncThreadPriority();
-
-                    ArrayList<Bitmap> images = data.generatedImages;
-                    ArrayList<Bitmap> srcImages = data.sourceImages;
-                    int count = srcImages.size();
-                    Canvas c = new Canvas();
-                    for (int i = 0; i < count && !task.isCancelled(); ++i) {
-                        // Before work on each item, ensure that this task is running at the correct
-                        // priority
+                    try {
+                        // Ensure that this task starts running at the correct priority
                         task.syncThreadPriority();
 
-                        Bitmap b = srcImages.get(i);
-                        Bitmap outline = Bitmap.createBitmap(b.getWidth(), b.getHeight(),
-                                Bitmap.Config.ARGB_8888);
+                        ArrayList<Bitmap> images = data.generatedImages;
+                        ArrayList<Bitmap> srcImages = data.sourceImages;
+                        int count = srcImages.size();
+                        Canvas c = new Canvas();
+                        for (int i = 0; i < count && !task.isCancelled(); ++i) {
+                            // Before work on each item, ensure that this task is running at the correct
+                            // priority
+                            task.syncThreadPriority();
 
-                        c.setBitmap(outline);
-                        c.save();
-                        c.drawBitmap(b, 0, 0, null);
-                        c.restore();
-                        c.setBitmap(null);
+                            Bitmap b = srcImages.get(i);
+                            Bitmap outline = Bitmap.createBitmap(b.getWidth(), b.getHeight(),
+                                    Bitmap.Config.ARGB_8888);
 
-                        images.add(outline);
+                            c.setBitmap(outline);
+                            c.save();
+                            c.drawBitmap(b, 0, 0, null);
+                            c.restore();
+                            c.setBitmap(null);
+
+                            images.add(outline);
+                        }
+                    } finally {
+                        if (task.isCancelled()) {
+                            data.cleanup(true);
+                        }
                     }
                 }
             },
             new AsyncTaskCallback() {
                 @Override
                 public void run(AppsCustomizeAsyncTask task, AsyncTaskPageData data) {
-                    mRunningTasks.remove(task);
-                    if (task.isCancelled()) return;
-                    if (task.page > getPageCount()) return;
-                    if (task.pageContentType != mContentType) return;
-                    onHolographicPageItemsLoaded(data);
+                    try {
+                        mRunningTasks.remove(task);
+                        if (task.isCancelled()) return;
+                        if (task.page > getPageCount()) return;
+                        if (task.pageContentType != mContentType) return;
+                        onHolographicPageItemsLoaded(data);
+                    } finally {
+                        data.cleanup(task.isCancelled());
+                    }
                 }
             });
 
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java
index 053c2ea..4e06570 100644
--- a/src/com/android/launcher2/PagedViewWidget.java
+++ b/src/com/android/launcher2/PagedViewWidget.java
@@ -96,6 +96,20 @@
         setClipToPadding(false);
     }
 
+    @Override
+    protected void onDetachedFromWindow() {
+        super.onDetachedFromWindow();
+
+        final ImageView image = (ImageView) findViewById(R.id.widget_preview);
+        if (image != null) {
+            FastBitmapDrawable preview = (FastBitmapDrawable) image.getDrawable();
+            if (preview != null && preview.getBitmap() != null) {
+                preview.getBitmap().recycle();
+            }
+            image.setImageDrawable(null);
+        }
+    }
+
     public void applyFromAppWidgetProviderInfo(AppWidgetProviderInfo info,
             FastBitmapDrawable preview, int maxWidth, int[] cellSpan,
             HolographicOutlineHelper holoOutlineHelper) {
@@ -109,11 +123,9 @@
         mPreviewImageView = image;
         final TextView name = (TextView) findViewById(R.id.widget_name);
         name.setText(info.label);
-        name.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
         final TextView dims = (TextView) findViewById(R.id.widget_dims);
         if (dims != null) {
             dims.setText(String.format(mDimensionsFormatString, cellSpan[0], cellSpan[1]));
-            dims.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
         }
     }
 
@@ -127,11 +139,9 @@
         mPreviewImageView = image;
         final TextView name = (TextView) findViewById(R.id.widget_name);
         name.setText(label);
-        name.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
         final TextView dims = (TextView) findViewById(R.id.widget_dims);
         if (dims != null) {
             dims.setText(String.format(mDimensionsFormatString, 1, 1));
-            dims.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
         }
     }
 
