alexcorvi / heic2any

Converting HEIF/HEIF image formats to PNG/GIF/JPEG in the browser
https://alexcorvi.github.io/heic2any/
MIT License
585 stars 74 forks source link

Memory leak in decodeBuffer #29

Open chebum opened 2 years ago

chebum commented 2 years ago

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

Hajzenberg commented 2 years ago

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

Is there npm of this fork?

chebum commented 2 years ago

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

tlloydukdev commented 2 months ago

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