intravenous icon indicating copy to clipboard operation
intravenous copied to clipboard

Memory leak fix using factories

Open shuky19 opened this issue 8 years ago • 0 comments

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);

shuky19 avatar Feb 03 '16 20:02 shuky19