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

Using all ram #42

Open
mctrivia opened this issue Jul 27, 2022 · 1 comment
Open

Using all ram #42

mctrivia opened this issue Jul 27, 2022 · 1 comment

Comments

@mctrivia
Copy link

mctrivia commented Jul 27, 2022

I am using the following function to try and create a thumbnail of a gif with a mask. icon.data is a buffer containing the gif data. The addMask function works with JIMP variables and works. even if I comment out the line that manipulates the frame it uses up all the ram and crashes with a FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

            let sourceGif=await codec.decodeGif(icon.data);
            for (let i in sourceGif.frames) {
                let frameImage = GifUtil.copyAsJimp(Jimp, sourceGif.frames[i]);
                //frameImage=await addMask(frameImage,icon); //function that resizes a frame and adds a mask to the frame 
                sourceGif.frames[i]=new GifFrame(frameImage.bitmap);
            }
            GifUtil.quantizeDekker(sourceGif.frames, 256);

            // The encoder determines GIF size from the frames, not the provided spec (sourceGif).
            outputBuffer=codec.encodeGif(sourceGif.frames, sourceGif);

After some more checks I find that it is the GifUtil.quantizeDekker function causing the problem.

@mctrivia
Copy link
Author

ran some tests. GifUtil.quantizeDekker uses about 20MB of ram for each 350x350px frame in my gif. So at frame 166 it goes over 4GB of ram. So its currently using 163 bytes per pixel. Only way to fix would be to make more efficient.

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

1 participant