When building advanced JS-interfaces and games I've found that I have to dig deeper in to how browsers handles memory for JS. My experience with memory and JavaScript is that the memory gets glogged (and makes animations and calculation slow/lagging ) when:

  • There is alot of JS-generated content on the page
  • There is alot of graphics (img-elements) on the page?

I have therefore concluded that if I want to keep my memory fresh I should include as much HTML code as possible from the beginning of the document as it will be cached and not kept in memory. And off course remove all currently not used elements.

Does anyone have any more info on this? Resources? Links?

  • to tough and boring for ya huh?? xP Jens Hedqvist almost 10 years ago
  • Apparently so :) You might have more sense with the more tech-oriented audience over at stackoverflow.com. Olly Hodgson almost 10 years ago
  • Good advice. I'll take that. :) Jens Hedqvist almost 10 years ago

2 answers

1
point
This was chosen as the best answer

I'm no expert on these things, but I've run into some memory-related issues in the past. Internet Explorer used to suffer horribly from memory leaks, especially with closures. There's a utility called Drip which can help you keep an eye on them.

Edit: It looks like sIEve has superceded Drip.

Answered almost 10 years ago by Olly Hodgson
0
points

AJAX is your friend. jQuery has some wonderful implementations that are fairly robust and can probably handle everything you're trying to accomplish.

one thing to note about browsers is that you only have a small sandbox to play in. In most cases you can not take advantage of the full CPU or any Hardware when using strictly HTML/ and JavaScript. That is one of the big reasons for the existence of plug-ins like Flash/Silverlight/etc.

I'm actually pretty interested in HTML5 and how the browser sandbox will handle all the new functionality that will be added.

Answered almost 10 years ago by Discorax
  • Hmm. jQuery is a tool, it's how you use it that makes the differance. I've just got some great answers over att stackoverflow on Page Reflow problems, grea stuff: http://www.slideshare.net/lsimon/go-with-the-reflow. But yes the sandbox is very small, that I've noticed :) Jens Hedqvist almost 10 years ago