From 08d7778f081aae745e6ad9e5350221b21dbf352e Mon Sep 17 00:00:00 2001 From: Kimiyoshi Kusaka Date: Mon, 28 Mar 2011 11:58:51 +0900 Subject: Fix memory leak of SkMovie class Movie class doesn't have finalize method. So memory leak of SkMovie class of native Skia occurs when Movie class is released. I add finalize method to Movie class (Movie.java) and jni destructor method to SkMovie class (Movie.cpp). Change-Id: I4dae9dd95f128cbfade50bef978b219ba99321dd --- graphics/java/android/graphics/Movie.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'graphics') diff --git a/graphics/java/android/graphics/Movie.java b/graphics/java/android/graphics/Movie.java index 95e9946..4a33453 100644 --- a/graphics/java/android/graphics/Movie.java +++ b/graphics/java/android/graphics/Movie.java @@ -46,6 +46,8 @@ public class Movie { public static native Movie decodeByteArray(byte[] data, int offset, int length); + private static native void nativeDestructor(int nativeMovie); + public static Movie decodeFile(String pathName) { InputStream is; try { @@ -57,6 +59,15 @@ public class Movie { return decodeTempStream(is); } + @Override + protected void finalize() throws Throwable { + try { + nativeDestructor(mNativeMovie); + } finally { + super.finalize(); + } + } + private static Movie decodeTempStream(InputStream is) { Movie moov = null; try { -- cgit v1.1