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. 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). 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. Keep in mind the following when implementing or refactoring an Angular app. 2.

This was the biggest win for our app. 3. 4. $watch with only 2 parameters, is fast. 5. Measuring Performance. Memory Management - JavaScript | MDN. 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. 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. 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 Garbage collection Example. 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. StrongLoop | 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). Eventually it got ported to the server as a high performance engine for running server side JavaScript and became the basis of Node. But, just like any server side runtime like the JVM or CLR, V8 runs on memory and needs memory management. Who/What is the Garbage Collector? Performance wise, it is a wash. Short GC/scavenging.