heic2any icon indicating copy to clipboard operation
heic2any copied to clipboard

Memory leak in decodeBuffer

Open chebum opened this issue 2 years ago • 3 comments

The following code creates a new function reference and never frees it.

https://github.com/alexcorvi/heic2any/blob/3222e591896ce72cf293a37f5a083cde5fc348c7/src/heic2any.ts#L202-L212

Subsequent calls to heic2any will create a new instance of the message handler. Both handlers will be called. Converting Nth image will create Nth event handler and all N handler will receive message notifications.

Proposed fix: https://github.com/chebum/heic2any/commit/c6fab0ac088ea988d38d5e9452d9b6a9bb0fe6ed

Fixed heic2any.js is available here: https://github.com/chebum/heic2any/tree/master/dist

The fix also includes pull request #27

chebum avatar Dec 10 '21 19:12 chebum

Fixed heic2any.js is available here: https://github.com/chebum/heic2any/tree/master/dist

Is there npm of this fork?

Hajzenberg avatar Jan 16 '22 23:01 Hajzenberg

Fixed heic2any.js is available here: https://github.com/chebum/heic2any/tree/master/dist

Is there npm of this fork?

You can install it as below:

npm install --save github:chebum/heic2any

chebum avatar Jan 27 '22 21:01 chebum

thanks for this awesome contribution. as time has gone on now, I see HEIC files taking up 500MB to convert in the browser Memory tab. the end result is the browser is restarted on iOS/Android. desktop browser copes, I guess it has larger memory resource available

tlloydukdev avatar Apr 24 '24 13:04 tlloydukdev