K
K
krll-k2016-04-19 01:20:47
JavaScript
krll-k, 2016-04-19 01:20:47

NodeJs clogged memory, what to do?

var jsdom = require("jsdom");

var cities = ["spb.domru.ru","rostov.domru.ru","kazan.domru.ru",];//"tver.domru.ru","nsk.domru.ru","ufa.domru.ru","nn.domru.ru","chel.domru.ru","tmn.domru.ru","penza.domru.ru","ryazan.domru.ru","barnaul.domru.ru","tula.domru.ru","ekat.domru.ru","izhevsk.domru.ru","yar.domru.ru","irkutsk.domru.ru","kirov.domru.ru","krsk.domru.ru","chelny.domru.ru","ulsk.domru.ru","bryansk.domru.ru","kursk.domru.ru","mgn.domru.ru","tomsk.domru.ru","samara.domru.ru","saratov.domru.ru","volgograd.domru.ru","omsk.domru.ru","oren.domru.ru","voronezh.domru.ru","lipetsk.domru.ru","cheb.domru.ru","yola.domru.ru","kurgan.domru.ru","perm.domru.ru"];

var data = [];

cities.forEach(function(item, i, cities) {
  
  jsdom.env(
    "http://" + item + "/bundles/",
    ["http://code.jquery.com/jquery.js"],
    function (err, window) {
      var price = {};

      price.xs = Number(window.$(".js-price-not-phone-XS:first").text().replace(/\D+/g,""));
      price.s = Number(window.$(".js-price-not-phone-S:first").text().replace(/\D+/g,""));
      price.l = Number(window.$(".js-price-not-phone-L:first").text().replace(/\D+/g,""));
      price.m = Number(window.$(".js-price-not-phone-M:first").text().replace(/\D+/g,""));
      price.xxl = Number(window.$(".js-price-not-phone-XXL:first").text().replace(/\D+/g,""));
    	
    	console.log(item, price);
    }
  );

});

C:\Users\Общий\Desktop\dom_ru_parser>node tarifs.js

<--- Last few GCs --->

   97840 ms: Mark-sweep 529.2 (744520.1) -> 529.2 (771595.1) MB, 1174.2 / 0 ms [allocation failure] [GC in old space requested].
   98448 ms: Mark-sweep 529.2 (771596.1) -> 456.8 (771598.1) MB, 606.7 / 0 ms [allocation failure] [GC in old space requested].
   99001 ms: Mark-sweep 461.0 (771598.1) -> 458.5 (771598.1) MB, 516.1 / 0 ms [allocation failure] [scavenge might not succeed].

C:\Users\Общий\Desktop\dom_ru_parser>node tarifs.js
{ xs: 450, s: 0, l: 785, m: 650, xxl: 1050 }
{ xs: 0, s: 0, l: 785, m: 650, xxl: 1050 }
{ xs: 550, s: 0, l: 785, m: 650, xxl: 1050 }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question