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

Fixes #31 Memory leak in 0.9.12 #32

Merged
merged 1 commit into from
Aug 1, 2015
Merged

Fixes #31 Memory leak in 0.9.12 #32

merged 1 commit into from
Aug 1, 2015

Conversation

d3m3vilurr
Copy link
Collaborator

Simple test case:

var immediately = function(cb) {
    sync.fiber(function() {
        setImmediate(sync.defer());
        sync.await();
    }, cb);
};

function test(m, cb) {
    if (m-- === 0) return cb();
    immediately(function(err) {
        if (err) return cb(err);
        if (m % 1000 === 0) {
            console.log(m + ": " + JSON.stringify(process.memoryUsage()));
        }
        test(m, cb);
    });
}

test(100000000, function(err) {
        if (err) throw err;
        console.log("done");
});

Before:
99888000: {"rss":114892800,"heapTotal":81994496,"heapUsed":58052656}
99887000: {"rss":115163136,"heapTotal":81994496,"heapUsed":59327264}
99886000: {"rss":115433472,"heapTotal":83026432,"heapUsed":60601944}
99885000: {"rss":115703808,"heapTotal":83026432,"heapUsed":61877016}
99884000: {"rss":115974144,"heapTotal":83026432,"heapUsed":63152072}
99883000: {"rss":120840192,"heapTotal":87154176,"heapUsed":56497944}
99882000: {"rss":121110528,"heapTotal":87154176,"heapUsed":57772688}

After:
99687000: {"rss":74567680,"heapTotal":60323840,"heapUsed":36945504}
99686000: {"rss":74567680,"heapTotal":60323840,"heapUsed":38211632}
99685000: {"rss":74510336,"heapTotal":59291904,"heapUsed":16835640}
99684000: {"rss":74510336,"heapTotal":59291904,"heapUsed":18102288}
99683000: {"rss":74510336,"heapTotal":59291904,"heapUsed":19368336}
99682000: {"rss":74510336,"heapTotal":59291904,"heapUsed":20634792}
99681000: {"rss":74510336,"heapTotal":59291904,"heapUsed":21900840}
99680000: {"rss":74510336,"heapTotal":59291904,"heapUsed":23166888}
99679000: {"rss":74510336,"heapTotal":59291904,"heapUsed":24432936}

Simple test case:

    var immediately = function(cb) {
        sync.fiber(function() {
            setImmediate(sync.defer());
            sync.await();
        }, cb);
    };

    function test(m, cb) {
        if (m-- === 0) return cb();
        immediately(function(err) {
            if (err) return cb(err);
            if (m % 1000 === 0) {
                console.log(m + ": " + JSON.stringify(process.memoryUsage()));
            }
            test(m, cb);
        });
    }

    test(100000000, function(err) {
            if (err) throw err;
            console.log("done");
    });

Before:
    99888000: {"rss":114892800,"heapTotal":81994496,"heapUsed":58052656}
    99887000: {"rss":115163136,"heapTotal":81994496,"heapUsed":59327264}
    99886000: {"rss":115433472,"heapTotal":83026432,"heapUsed":60601944}
    99885000: {"rss":115703808,"heapTotal":83026432,"heapUsed":61877016}
    99884000: {"rss":115974144,"heapTotal":83026432,"heapUsed":63152072}
    99883000: {"rss":120840192,"heapTotal":87154176,"heapUsed":56497944}
    99882000: {"rss":121110528,"heapTotal":87154176,"heapUsed":57772688}

After:
    99687000: {"rss":74567680,"heapTotal":60323840,"heapUsed":36945504}
    99686000: {"rss":74567680,"heapTotal":60323840,"heapUsed":38211632}
    99685000: {"rss":74510336,"heapTotal":59291904,"heapUsed":16835640}
    99684000: {"rss":74510336,"heapTotal":59291904,"heapUsed":18102288}
    99683000: {"rss":74510336,"heapTotal":59291904,"heapUsed":19368336}
    99682000: {"rss":74510336,"heapTotal":59291904,"heapUsed":20634792}
    99681000: {"rss":74510336,"heapTotal":59291904,"heapUsed":21900840}
    99680000: {"rss":74510336,"heapTotal":59291904,"heapUsed":23166888}
    99679000: {"rss":74510336,"heapTotal":59291904,"heapUsed":24432936}
@bradvogel
Copy link
Collaborator

We tested this in production (with very high volume) today and it appears to work well. Thanks!

@bradvogel
Copy link
Collaborator

Please bump npm version also

@bradvogel
Copy link
Collaborator

@alexeyPetrushin can you merge this? This regression is very severe and probably affecting many others.

al6x added a commit that referenced this pull request Aug 1, 2015
Fixes #31 Memory leak in 0.9.12
@al6x al6x merged commit 2c1892d into al6x:master Aug 1, 2015
@al6x
Copy link
Owner

al6x commented Aug 1, 2015

Hi, sorry for delay, moved to a new house and was couple of days without internet...
Thanks for fix, will merge it immediately.

@al6x
Copy link
Owner

al6x commented Aug 1, 2015

Released as 0.9.14

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

Successfully merging this pull request may close these issues.

3 participants