Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak in decodeBuffer #29

Open
chebum opened this issue Dec 10, 2021 · 3 comments
Open

Memory leak in decodeBuffer #29

chebum opened this issue Dec 10, 2021 · 3 comments

Comments

@chebum
Copy link

chebum commented Dec 10, 2021

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

heic2any/src/heic2any.ts

Lines 202 to 212 in 3222e59

((window as any).__heic2any__worker as Worker).addEventListener(
"message",
(message) => {
if (message.data.id === id) {
if (message.data.error) {
return reject(message.data.error);
}
return resolve(message.data.imageDataArr);
}
}
);

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: chebum@c6fab0a

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

The fix also includes pull request #27

@Hajzenberg
Copy link

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

Is there npm of this fork?

@chebum
Copy link
Author

chebum commented Jan 27, 2022

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants