/    Sign up×
Community /Pin to ProfileBookmark

Javascript Memory Leak

Good morning, I deal with mainly PHP but have some AJAX on my website, I seem to have a memory leak in my AJAX and don’t know what is wrong, If anyone has any ideas that would be great, maybe I am not taking care of my closures.

[CODE]
<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js”></script>

function updateLobby() {
me = $.ajax({
url: “./includes/ajax/ajax.game_lobby.php?g=”+24,
cache: false,
async: false
}).responseText;

document.getElementById(“right_pane1”).innerHTML=me;
me = null;

setInterval(function() {
me = $.ajax({
url: “./includes/ajax/ajax.game_lobby.php?g=”+24+”&n=1”,
cache: false,
async: false
}).responseText;
if (me == 1) {
me = $.ajax({
url: “./includes/ajax/ajax.game_lobby.php?g=”+24,
cache: false,
async: false
}).responseText;
document.getElementById(“right_pane1”).innerHTML=me;
me = null;
}
}, 5000)
}

updateLobby();

</script> [/CODE]

Essentially this code serves two purposes, at first it pulls in the current users in a lobby, it then has an interval where it checks if anything has changed to the lobby, (if users have entered or left) if they have it will proceed to update the div element, otherwise it doesn’t modify the div. I have some other ajax on the page but I think I have narrowed it down to this bit of code.

Thanks for your help.

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @greenfalcon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...