Skip to content

Memory leak in Image #785

Closed
Closed
@kkaefer

Description

@kkaefer

When constructing an Image, memory for that image seems to never be released:

var fs = require('fs');
var Canvas = require('canvas');
var Image = Canvas.Image;

var filename = 'image.png';
var data = fs.readFileSync(filename);

function load() {
    var img = new Image;
    img.onload = function() {
        process.nextTick(load);
        global.gc();
    };
    img.src = data;
}

load();

This code uses global.gc() to force garbage collection, but even then, memory rises very quickly. When moving the var img = new Image; to outside the load function (and effectively reusing it) changes memory usage behavior to near constant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions