Skip to content

Commit

Permalink
Attempt to reduce memory usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
jarib committed Aug 1, 2015
1 parent 8b37918 commit cc1f2e4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
16 changes: 15 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
{
"stage": 0
"stage": 0,
"optional": [
"runtime",
"optimisation",
"minification.memberExpressionLiterals",
"minification.propertyLiterals",
"optimisation.flow.forOf",
"optimisation.modules.system",
],
"loose": ["all"],
"compact": true,
"comments": false,
"ast": false,
"nonStandard": false,
"only": ["lib/Scraper.js"]
}
12 changes: 11 additions & 1 deletion lib/Scraper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ import slug from 'slug';
import util from 'util';
import { Iconv } from 'iconv';

if (global.gc) {
for (var i = 0; i < 50; i++) {
console.log(process.memoryUsage().rss / (1024 * 1024));
gc();
console.log(process.memoryUsage().rss / (1024 * 1024));
};
} else {
global.gc = (() => {});
}

const request = Promise.promisify(requestRaw);
const USER_AGENT = 'pollofpolls-scraper | https://github.com/jarib/pollofpolls-scraper';
const DATE = moment().format('YYYY-MM-DD');
Expand Down Expand Up @@ -121,7 +131,7 @@ export default class Scraper {
name,
date,
...results
});
}).then(gc);
});
});
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"dependencies": {
"babel": "^5.8.20",
"babel-runtime": "^5.8.20",
"bluebird": "^2.9.34",
"cheerio": "^0.19.0",
"iconv": "^2.1.8",
Expand Down

0 comments on commit cc1f2e4

Please sign in to comment.