我开发了chrome(后台插件)插件。但是,我认为我有内存泄漏。你可以帮帮我吗 ?当我使用chrome profiler时,我可以看到
"use strict";
var URL = 'https://api.mysite.org/messages';
var ajax;
var intervalId;
var notification;
function onInterval() {
updateData();
}
function updateData() {
if (intervalId) {
window.clearTimeout(intervalId);
}
if (ajax) {
ajax.abort();
ajax = null;
}
intervalId = window.setTimeout(onInterval, 1000 * 60);
executeAjax();
}
function executeAjax() {
ajax = $.ajax({
type: 'GET',
timeout: 1000 * 10,
dataType: 'json',
url: URL,
cache: false
});
ajax.done(done);
ajax.fail(error);
}
function done(rawData) {
var tmp = rawData.messages;
if (tmp != null) {
notify(tmp);
}
}
function notify(icon, newStatus, message) {
var options = {
title : 'New Message',
priority : 0,
iconUrl : 'icon/notif.png'
};
options.type = 'basic';
options.message = message;
chrome.notifications.create('', options);
}
$(document).ready(onInterval);
错误暂时是一个空函数