fix(core): recycle intermediate bitmap in PhotoProcessor.loadSampled to prevent memory leak

This commit is contained in:
xfy 2026-07-24 13:33:35 +08:00
parent 7bf16dfe5a
commit 1b2fcfe248

View File

@ -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
}
/**