全部,
我正在实现一个彗星 JS 库。现在我正在跟踪响应文本的大小并在块到达时返回新部分。这为我的回调提供了新数据,但这是一个非常明显的内存泄漏。有没有办法强制关闭 XMLHttpRequest 对象或定期重置 responseText 的内容?
request.multi = function(type, handler, url, querystring){
querystring = (querystring == undefined) ? null: querystring;
var response = "";
var handle = makeRequestHandle();
handle.multipart = true;
handle.open(type, url, true);
handle.onreadystatechange = function(){
var return_val;
if(handle.readyState == 4){
m_log.debug("Conection died");
}else if(handle.readyState == 3){
return_val = handle.responseText.substring(response.length);
response = handle.responseText;
handler(return_val);
}else{
m_log.debug("readyState %s", handle.readyState);
}
};
handle.send(querystring);
}