gc-hacks
Collection of ugly hacks, for JS garbage collector. Use only as a last resort.
Code based on disscussion from this thread.
And I higly recomend to read it before using this module.
Big thanks to @adamhooper for code suggestion and great advice:
And don't use these workarounds normally. Only use them when you have identified a problem and you are certain this fixes the problem, and you have commented why it fixes the problem.
Installation
npm install gc-hacks
Usage
var gcHacks = require('gc-hacks');
var veryLongString = 'xxxxxxxxxxxxxxxxxxxxx...';
var partString = veryLongString.substr(1);
partString = forceStringCopy(partString);
var array = [veryLongString.substr(1)];
array = recreateValue(array);
gcHacks.gcCollect();
var hackedFunction = gcHacks.recreateReturnObjectAndGcCollect(someFunction);
somePromise
.then(gcHacks.recreateReturnObjectAndGcCollect(function (arg1, arg2) {
return [veryLongString.substr(1)];
})