Skip to content

Possible memory leak? #260

@pajtai

Description

@pajtai

I have a definite memory leak in my app, and I'm trying to narrow it down.

The smallest bit of code that I can comment out to remove the leak seems to be (I've reduce the sharp calls to be as minimal as possible):

                                new sharp(bodyBuffer)
                                    .resize(width - 0, height)
                                    .toBuffer(resizedFileName)
                                    .then(function() {
                                        res.send('ok');
                                    })
                                    .catch(function(error) {
                                        console.log('errrrr', error);
                                    });

If I replace the above with

res.send('ok');

The leak goes away.

Is there anything I should be closing after the resize? I was thinking about maybe setting this.options.bufferIn to null at some point? One thing I've noticed is that the 'finish' event is never fired... so if I do:

                         var s     =  new sharp(bodyBuffer)
                                    .resize(width - 0, height);
                       s.on('finish',function() { console.log('done'});

the console log never fires.... but the images are definitely getting resized properly.

Thanks for any suggestions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions