background preloader

JS performance

Facebook Twitter

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.

11 Tips to Improve AngularJS Performance

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. Angular uses dirty checking to keep track of all the changes in app.

This means it will have to go through every watcher to check if they need to be updated (call the digest cycle). If one of the watcher is relied upon by another watcher, Angular would have to re-run the digest cycle again, to make sure that all of the changes has propagated. Even though running JavaScript in modern browsers is really fast, in Angular it is fairly easy to add so many watchers that you app will slow down to a crawl. 2. This was the biggest win for our app. 3. 4. Official doc: 5. Measuring Performance. Memory Management - JavaScript. Introduction Low-level languages, like C, have low-level memory management primitives like malloc() and free().

Memory Management - JavaScript

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. The latter process is called garbage collection. This "automatically" is a source of confusion and gives JavaScript (and high-level languages) developers the impression they can decide not to care about memory management. This is a mistake. Memory life cycle Regardless of the programming language, memory life cycle is pretty much always the same: Allocate the memory you need Use the allocated memory (read, write) Release the allocated memory when it is not needed anymore The first and second parts are explicit in all languages. Allocation in JavaScript Value initialization In order not to bother the programmer with allocations, JavaScript does it alongside with declaring values.

Allocation via function calls Using values Example. Memory leak patterns in JavaScript. JavaScript is a powerful scripting language used to add dynamic content to Web pages.

Memory leak patterns in JavaScript

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? 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.

Node.js Performance Tip of the Week: Managing Garbage Collection

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). In some systems or languages, it is up to the application program to manage all the bookkeeping details of allocating memory from the heap and freeing it when it is no longer required.

Who/What is the Garbage Collector? Performance wise, it is a wash. How does V8 Organize the heap? New-space: Most objects are allocated here.