XMLHttpRequest утечка памяти

sty-wolf

Новичок
Здравствуйте столкнулся с проблемой утечки памяти, гуглил многие сталкиваются с такой проблемой, а вот как решить проблему не понимаю, подскажите что надо сделать для решения проблемы

JavaScript:
ajax.prototype.clean=function() {
  this.error=false;
  this.txt=false;
  this.xml=false;
  this.state=0;
  this.loading=false;
  this.done=nothing;
  this.onerror=nothing;
  this.async=true;
  }

ajax.prototype.progress=function(i) {
  };

ajax.prototype.process=function() {
  if (!this.loading) return;
  this.state=this.req.readyState;
  this.progress(this.state);
  if (this.state === 4) {
    if (this.req.status === 200) {
      this.txt=this.req.responseText;
      this.xml=this.req.responseXML;
      this.progress(0);
      this.done();
      }
    else {
      alert('HTTP error: '+this.req.state+' '+this.req.status+' '+this.req.statusText);
      this.error=this.req.status;
      this.progress(0);
      this.onerror();
      }
    this.loading=false;
    }
  }

ajax.prototype.sendget=function(url) {
  if (!url) { alert('AJAX.SENDGET: No url!'); return; }
  this.url=url;
  if (this.async) this.progress(0);
  if (window.XMLHttpRequest) {
    this.req = new XMLHttpRequest();
    }
  else if (window.ActiveXObject) {
    this.req = new ActiveXObject("Microsoft.XMLHTTP");
    if (!this.req)
      this.req = new ActiveXObject("Msxml2.XMLHTTP");
    if (!this.req) {
      alert('AJAX.SENDGET: Cannot send XMLHttpRequest!');
      this.error=true; return false;
      }
    }
  var here=this;
  this.req.onreadystatechange=function () { here.process() }
  this.req.open('get',url,this.async);
  this.req.send(null);
  this.loading=true;
  if (!this.async) this.progress(0);
  return true;
  }
в гугли пишут надо куда то добавить req = null; // по завершении запроса удаляем ссылку из замыкания

а куда именно надо добавить?
 

c0dex

web.dev 2002-...
Команда форума
Партнер клуба
Форумом ошибся.

PS: moved.
 

fixxxer

К.О.
Партнер клуба
Этому коду лет больше, чем половине посетителей этого форума. ActiveX, my ass.

Надо удалить нахрен эту портянку с дедушкиной дискеты и написать одну строчку с fetch.
 
Сверху