From 1b2fcfe2489bcbbeae26718f243ba3efb3ae9b4a Mon Sep 17 00:00:00 2001 From: xfy Date: Fri, 24 Jul 2026 13:33:35 +0800 Subject: [PATCH] fix(core): recycle intermediate bitmap in PhotoProcessor.loadSampled to prevent memory leak --- core/src/main/kotlin/plus/rua/project/PhotoProcessor.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/kotlin/plus/rua/project/PhotoProcessor.kt b/core/src/main/kotlin/plus/rua/project/PhotoProcessor.kt index 7e0a03d..ce9404a 100644 --- a/core/src/main/kotlin/plus/rua/project/PhotoProcessor.kt +++ b/core/src/main/kotlin/plus/rua/project/PhotoProcessor.kt @@ -37,7 +37,12 @@ object PhotoProcessor { val bitmap = BitmapFactory.decodeFile(path, options) ?: error("无法加载图片: $path") val rotation = readExifRotation(path) - return if (rotation == 0) bitmap else rotate(bitmap, rotation) + if (rotation == 0) return bitmap + val rotated = rotate(bitmap, rotation) + if (rotated != bitmap && !bitmap.isRecycled) { + bitmap.recycle() + } + return rotated } /**