libheif icon indicating copy to clipboard operation
libheif copied to clipboard

Out of memory crash decoding 16MB HEIF image

Open larsxschneider opened this issue 1 year ago • 0 comments

I am using photoview which is importing HEIC/HEIF images with libheif v1.12.0 and I get the following error processing a HEIF image on machine with 4x32 bit ARM CPUs and 8GB of RAM (~4GB are usually free). What is special about this image is that it is a panorama image created on the iPhone 11 Pro with a file size of 15.8 MB (15,769,902 bytes) and an image size of 16382 × 3794 pixels.

runtime: out of memory: cannot allocate 251658240-byte block (863109120 in use)
fatal error: out of memory

goroutine 237700 [running]:
runtime.throw({0x9f3fae, 0xd})
	/usr/lib/go-1.18/src/runtime/panic.go:992 +0x5c fp=0xc11d850 sp=0xc11d83c pc=0x9334c
runtime.(*mcache).allocLarge(0x74b40538, 0xed18970, 0x1)
	/usr/lib/go-1.18/src/runtime/mcache.go:215 +0x1e4 fp=0xc11d878 sp=0xc11d850 pc=0x711c8
runtime.mallocgc(0xed18970, 0x954398, 0x1)
	/usr/lib/go-1.18/src/runtime/malloc.go:1096 +0x690 fp=0xc11d8b8 sp=0xc11d878 pc=0x6720c
runtime.makeslice(0x954398, 0xed18970, 0xed18970)
	/usr/lib/go-1.18/src/runtime/slice.go:103 +0xac fp=0xc11d8cc sp=0xc11d8b8 pc=0xac6f8
github.com/strukturag/libheif/go/heif.(*Image).GetImage(0xc0f66a0)
	/go/pkg/mod/github.com/strukturag/[email protected]/go/heif/heif.go:828 +0x5fc fp=0xc11d9e8 sp=0xc11d8cc pc=0x74febc
github.com/strukturag/libheif/go/heif.decodeImage({0xaf587c, 0x4b5b4a0})
	/go/pkg/mod/github.com/strukturag/[email protected]/go/heif/heif.go:1381 +0x98 fp=0xc11da08 sp=0xc11d9e8 pc=0x751e78
image.Decode({0xaf62b8, 0x8749fd0})

larsxschneider avatar Aug 22 '22 08:08 larsxschneider