background preloader

Memory leak patterns in JavaScript

Memory leak patterns in JavaScript
JavaScript is a powerful scripting language used to add dynamic content to Web pages. It is especially beneficial for everyday tasks such as password validation and creating dynamic menu components. While JavaScript is easy to learn and write, it is prone to memory leaks in certain browsers. In this introductory article we explain what causes memory leaks in JavaScript, demonstrate some of the common memory leak patterns to watch out for, and show you how to work around them. Note that the article assumes you are familiar with using JavaScript and DOM elements to develop Web applications. The article will be most useful to developers who use JavaScript for Web application development. Memory leaks in JavaScript JavaScript is a garbage collected language, meaning that memory is allocated to objects upon their creation and reclaimed by the browser when there are no more references to them. What's wrong with circular references? Listing 1. Another memory leak pattern Listing 2. Back to top

http://www.ibm.com/developerworks/library/wa-memleak/index.html

Related:  JS performance

Memory Management - JavaScript Introduction Low-level languages, like C, have low-level memory management primitives like malloc() and free(). On the other hand, JavaScript values are allocated when things (objects, strings, etc.) are created and "automatically" free'd when they are not used anymore.

Adding a JavaScript-based diff « Glen Smith Posted by Glen on Mar 17, 2011 in Grails, Groovy | 3 comments I’ve been on the hunt lately for some JavaScript based diffing routines.I’ve had a look at a few of them, and the one I’ve settled on is google-diff-match-patch which they use in the Grails wiki! (Thanks Peter Ledbrook for the pointer!) My particular need was around diffing a fairly complex “tree” structure. 3 ways to define a JavaScript class Introduction JavaScript is a very flexible object-oriented language when it comes to syntax. In this article you can find three ways of defining and instantiating an object. Even if you have already picked your favorite way of doing it, it helps to know some alternatives in order to read other people's code. It's important to note that there are no classes in JavaScript.

Memory leaks linkdump Page last changed today Since the comments to my previous posts contain a few useful links to memory leaks and closure resources, I thought I'd create a linkdump for future reference. Note that I only included those articles that explain what they're doing and why and give code examples. I ignored the pages that just throw scripts over the fence and leave it to the reader to figure out what they're all about. Node.js Performance Tip of the Week: Managing Garbage Collection In our last weekly performance tip, we discussed in detail how the Node.js event-loop works as the orchestrator of requests, events and callbacks. We also troubleshot a blocked event-loop which could wreck havoc on application performance. In this week’s post we’ll dive into the fundamentals of garbage collection (GC) in V8 and how it holds the “keys to the kingdom” in the optimization of Node applications. We will also look at some tools to triage GC and memory management issues in V8. Where did it all start Contrary to folklore, V8 was not designed explicitly for Node; rather was built to power a fast browser (Chrome/Chromium) or client side JavaScript (V8.NET).

A Full Javascript Architecture, Part Two - Chrome Extension In the first part of this series we saw how to create a simple Node server which tracks and broadcast tweets about the What’s Next event in real time. In this one we’ll see how to develop a Google Chrome extension that will display the tweets thanks to the HTML5 notification API. The extension will also use the Local Storage API and the Socket.IO client side library. Google Chrome Extensions RSS feeds Here's a list of RSS feeds I'm subscribed to, I'm using the Google Reader thing and check these usually once a day, sometimes several times a day, if I feel I need a break and don't have anything in mind. These have become de facto the way I get informed of what's up, my pretty limited view of the world, if you wish. Sometimes I feel a bit guilty of using the feeds, for example I don't visit SitePoint as much as before I subscribed to its feeds, therefore I'm not so exposed to their ads and so on, feels a bit like stealing. Anyway, on to the list. The list is ordered as Google Reader orders it, seems like alphabetically, only the first ones had some spaces in the names.

Javascript Closures Introduction Closure A "closure" is an expression (typically a function) that can have free variables together with an environment that binds those variables (that "closes" the expression). Closures are one of the most powerful features of ECMAScript (javascript) but they cannot be property exploited without understanding them. They are, however, relatively easy to create, even accidentally, and their creation has potentially harmful consequences, particularly in some relatively common web browser environments. To avoid accidentally encountering the drawbacks and to take advantage of the benefits they offer it is necessary to understand their mechanism.

11 Tips to Improve AngularJS Performance I am new to Angular (even though I am not new to the web development), so please take everything that I am about to say with a grain of salt. That being said, I watched a lot of talks and read a lot of articles relevant to Angular performance, and this post is the summary of my findings. Usually, if your Angular app is slow, it means that you either have too many watcher, or those watchers are working harder then they should.

Ultimate IE6 Cheatsheet: How To Fix 25+ Internet Explorer 6 Bugs inShare33 The best strategy for dealing with Internet Explorer 6 is not to support it. Stop.

Related: