简体   繁体   中英

JavaScript memory leaks causing page not to load?

I am running a simple game program with JavaScript and Brackets, and I came across a problem about the page not loading. I tried to run the game, and nothing happened, no information got to chrome about what it was running, it just loaded forever. I looked in the console, and I found that there were a bunch of memory leaks, but I haven't found anything about memory leaks causing the page to not load. I found that there was a certain line of code that when deleted let the page load, but it didn't make any sense.

I've google the problem, to which I found nothing.

Here's the line that causes the problem:

if (this.y + yOffSet < canvas.height / 6){
    yOffSet += canvas.height / 6 - (this.y + yOffSet);
}

Note: yOffSet is a global variable

Any Idea what might be the problem?

What about removing the + sign?

Just use yOffset = canvas.height / 6 - (this.y - yOffset)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM