Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Memory leak fix using factories #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

shuky19
Copy link

@shuky19 shuky19 commented Feb 3, 2016

This PR fixes a memory leak found in factories, where their container was never released from its parent container, add also specs to verify the fix

The following code will leak forever in the pre-fixed-version of intravenous:

// Heavy class
function heavyMemoryClass () {
this.array = new Array(1024*10);
}
heavyMemoryClass.$inject = [];

// Container configuration
var intravenous = require('intravenous');
var container = intravenous.create();
container.register('heavyMemoryClass', heavyMemoryClass, 'unique');

// Leak reproduction
var heavyMemoryClassFactory = container.get("heavyMemoryClassFactory");
setInterval(function () {
var myClass = heavyMemoryClassFactory.get();
heavyMemoryClassFactory.dispose(myClass);
}.bind(this), 10);

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

Successfully merging this pull request may close these issues.

1 participant