Microsoft Cloud Authors: Lori MacVittie, Elizabeth White, Yeshim Deniz, Serafima Al, Janakiram MSV

Related Topics: Microsoft Cloud, Machine Learning

Microsoft Cloud: Article

Garbage Collection in IE7

GC in IE7 is heavily impacted by number of JavaScript objects and string sizes

After my recent presentation at TSSJS – Performance Anti-Patterns in AJAX Applications - I got interesting feedback from one of the attendees: “The presentation was good but I thought you are talking more about actual problems with XHR/AJAX Requests”. I have to admit that I focused on all common problems of Web 2.0 applications – including network roundtrips, JavaScript and Rendering – and not just on those related to asynchronous communication. The comment made me work on a sample application where I want to test different approaches of asynchronous data processing that I’ve seen when working with our user base. I ran into a very interesting performance problem that I didn’t anticipate. So – before I write about the actual different approaches (XML vs. JSON, XHR vs. script tags, …) I want to share a performance problem in IE 7’s JavaScript engine that everybody should be aware of.

The more “active” JavaScript objects the slower your string manipulations

In my sample I process 1000 contact objects from two different data sources: XML and JSON. In case of XML I read element by element – create a JavaScript object and pass it to a method that appends the object’s content to a string buffer which will later be displayed on the page. In the JSON case I load all 1000 objects at once into an array and then hand each object to the same method by simply iterating over the array elements. Here is the pseudo code for my XML use case:

foreach(xmlElement in allXmlElements) {
var jsonObject = {};
jsonObject["firstName"] = xmlElement.getValueOf("firstName");
jsonObject["lastName"] = xmlElement.getValueOf("lastName");

And the pseudo code for JSON:

var allJsonObjects = eval(jsonObjectsAsString);
foreach(jsonObject in allJsonObjects) {

processObject itself is simply concatenating the individual properties of the JSON Object to a global string variable:

globalString += jsonObject.firstName + " " + jsonObject.lastName + ...

Running this example on Internet Explorer 7 is SLOW

I assumed that the 2nd use case (JSON) is much faster than the first as I assumed that iterating through the XML DOM is slower then parsing a string of JSON. Well, this assumption was correct (parsing through the XML is slower than parsing JSON), but the string concatenation in processObject turned out to be much slower in the JSON use case as compared to the XML use case.
Analyzing the JavaScript execution with the FREE dynaTrace AJAX Edition shows me all the 1000 invocations of processObject in both use case scenarios. In both cases execution time of the method increases over time – that is explained by a growing globalString object which gets more expensive to manipulate the larger the string grows. By the way, I know there are better ways to concatenate strings, and I should try out some of these recommendations. An excellent read here are the blogs from the guys at SitePen, e.g.: String Performance: An Analysis or String Performance: Getting Good Performance from Internet Explorer.

Let’s look at my results side-by-side showing the average execution time of processObject as well as the first couple of calls and the last couple of calls of the overall 1000 invocations of that method:

Execution Time Comparison between my two scenarios

Execution Time Comparison between my two scenarios

The left execution trace shows the JSON example where I constantly have 1000 JavaScript objects in memory (300ms). The right shows the XML example where I only have 1 JavsScript object in memory (150ms). The processObject method is called 1000 times in both scenarios and is doing exactly the same thing – concatenating the individual properties of the passed JavaScript object to a global string. The difference in execution time of these string concatenations, however, changes dramatically the longer the string gets. The only explanation I have for this “phenomenon” is that IE’s Memory Management is impacted greatly by having the additional 1000 JavaScript objects in memory (see my detailed analysis below the next image).

I copied the 1000 execution times of processObject for both use cases into an excel spreadsheet and graphed the timings. It’s interesting to see how the exec times change over time with an interesting spike at about 800 times the method was invoked:

JavaScript execution time over time

JavaScript execution time over time

The blue line shows the execution time of the scenario where I have the 1000 additional JavaScript objects in memory. The pink line shows the times with only 1 custom JavaScript object in memory. There are two interesting observations here – and I hope some of you (my fellow readers) can share your thoughts on it and correct me if my conclusions are incorrect: We see an increased exec time at the very beginning and a jump in execution time after about 800 executions of this method. I assume it has to do purely with the Garbage Collection and Object Allocation strategy of IE. Daniel Pupius’ blog about Garbage Collection in IE6 gives some answers on when IE kicks of the GC (after 256 variable allocations, 4096 array slot allocations and 64kb of String allocations). I am sure Microsoft has changed the GC strategy for IE7 but Daniel’s blog definitely explains the spike in my graph. My string size ends up being 79k. After about 800 executions it crosses the 64kb limit. Interesting is that from that point on I have constantly high execution times. So – the GC always runs when you have strings larger than 64kb!! I explain the individual smaller spikes with the GC runs triggered by 256 variable allocations. What I can’t explain is the much higher execution times in the very beginning – any thoughts?

Key takeaway: Be careful with string allocations and objects in memory -> GC in IE7 performs really badly

Running this example on IE8, FireFox and Chrome is FAST

I ran the same example on Internet Explorer 8, FireFox 3.6 and the latest version of Chrome. Not surprisingly the execution time on all of these latest versions of these browsers where between 2 and 15ms. These timings were the same for both use case scenarios (1 and 1000 objects in memory). Chrome and FireFox were in fact the fastest with only 2ms of execution time. IE8 took 15ms. The following graph shows the comparison between the tested browsers:

String Concatenation Times across Browsers

String Concatenation Times across Browsers


First of all – here is the actual sample I used. Click on the 1000 Objects and 1000 Objects (wArray). Test it on your machine and let me know if you experience any different behavior. I am also very happy to accept any recommendations on how to speed up this sample – I am sure there are many ways of doing so.

Second – it is important to understand the browsers internal memory management and the GC strategies. IE 7 will be here for a long long time so be careful with your object allocations. It also shows how important it is to test and analyze performance across browsers – especially on Internet Explorer. Most developers that I meet don’t use IE at all and purely focus on FF, Chrome or Safari. This often leads to the fact that problems like this here won’t show up until late in the project (when testers are testing the software across browsers and platforms) or when the page hits “The Real User” who happens to use IE quite a lot.

Third and final conclusion – I hope this was helpful. As always – if you are interested in more information check out some of the other AJAX Related blogs and watch some of the webinars we recorded with our clients, e.g.: the one I did with Monster.com.

Related reading:

  1. .NET Performance Analysis: A .NET Garbage Collection Mystery Memory Management in .NET is a broad topic with a...
  2. Week 8 – Challenges in Tracing JavaScript Performance by Example In an earlier post I already discussed several approaches towards...
  3. Performance Analysis of dynamic JavaScript Menus In my previous post I talked about the impact of...
  4. Performance Analysis: How to identify “bad” methods messing up the GC Whenever the Garbage Collector kicks in to free up memory...

More Stories By Andreas Grabner

Andreas Grabner has been helping companies improve their application performance for 15+ years. He is a regular contributor within Web Performance and DevOps communities and a prolific speaker at user groups and conferences around the world. Reach him at @grabnerandi

@ThingsExpo Stories
Gemini is Yahoo’s native and search advertising platform. To ensure the quality of a complex distributed system that spans multiple products and components and across various desktop websites and mobile app and web experiences – both Yahoo owned and operated and third-party syndication (supply), with complex interaction with more than a billion users and numerous advertisers globally (demand) – it becomes imperative to automate a set of end-to-end tests 24x7 to detect bugs and regression. In th...
Michael Maximilien, better known as max or Dr. Max, is a computer scientist with IBM. At IBM Research Triangle Park, he was a principal engineer for the worldwide industry point-of-sale standard: JavaPOS. At IBM Research, some highlights include pioneering research on semantic Web services, mashups, and cloud computing, and platform-as-a-service. He joined the IBM Cloud Labs in 2014 and works closely with Pivotal Inc., to help make the Cloud Found the best PaaS.
Cloud-enabled transformation has evolved from cost saving measure to business innovation strategy -- one that combines the cloud with cognitive capabilities to drive market disruption. Learn how you can achieve the insight and agility you need to gain a competitive advantage. Industry-acclaimed CTO and cloud expert, Shankar Kalyana presents. Only the most exceptional IBMers are appointed with the rare distinction of IBM Fellow, the highest technical honor in the company. Shankar has also receive...
"Evatronix provides design services to companies that need to integrate the IoT technology in their products but they don't necessarily have the expertise, knowledge and design team to do so," explained Adam Morawiec, VP of Business Development at Evatronix, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Business professionals no longer wonder if they'll migrate to the cloud; it's now a matter of when. The cloud environment has proved to be a major force in transitioning to an agile business model that enables quick decisions and fast implementation that solidify customer relationships. And when the cloud is combined with the power of cognitive computing, it drives innovation and transformation that achieves astounding competitive advantage.
The Founder of NostaLab and a member of the Google Health Advisory Board, John is a unique combination of strategic thinker, marketer and entrepreneur. His career was built on the "science of advertising" combining strategy, creativity and marketing for industry-leading results. Combined with his ability to communicate complicated scientific concepts in a way that consumers and scientists alike can appreciate, John is a sought-after speaker for conferences on the forefront of healthcare science,...
Data is the fuel that drives the machine learning algorithmic engines and ultimately provides the business value. In his session at Cloud Expo, Ed Featherston, a director and senior enterprise architect at Collaborative Consulting, discussed the key considerations around quality, volume, timeliness, and pedigree that must be dealt with in order to properly fuel that engine.
Explosive growth in connected devices. Enormous amounts of data for collection and analysis. Critical use of data for split-second decision making and actionable information. All three are factors in making the Internet of Things a reality. Yet, any one factor would have an IT organization pondering its infrastructure strategy. How should your organization enhance its IT framework to enable an Internet of Things implementation? In his session at @ThingsExpo, James Kirkland, Red Hat's Chief Archi...
The current age of digital transformation means that IT organizations must adapt their toolset to cover all digital experiences, beyond just the end users’. Today’s businesses can no longer focus solely on the digital interactions they manage with employees or customers; they must now contend with non-traditional factors. Whether it's the power of brand to make or break a company, the need to monitor across all locations 24/7, or the ability to proactively resolve issues, companies must adapt to...
In his keynote at 18th Cloud Expo, Andrew Keys, Co-Founder of ConsenSys Enterprise, provided an overview of the evolution of the Internet and the Database and the future of their combination – the Blockchain. Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settl...
Organizations planning enterprise data center consolidation and modernization projects are faced with a challenging, costly reality. Requirements to deploy modern, cloud-native applications simultaneously with traditional client/server applications are almost impossible to achieve with hardware-centric enterprise infrastructure. Compute and network infrastructure are fast moving down a software-defined path, but storage has been a laggard. Until now.
In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
DXWorldEXPO LLC announced today that the upcoming DXWorldEXPO | CloudEXPO New York event will feature 10 companies from Poland to participate at the "Poland Digital Transformation Pavilion" on November 12-13, 2018.
Digital Transformation is much more than a buzzword. The radical shift to digital mechanisms for almost every process is evident across all industries and verticals. This is often especially true in financial services, where the legacy environment is many times unable to keep up with the rapidly shifting demands of the consumer. The constant pressure to provide complete, omnichannel delivery of customer-facing solutions to meet both regulatory and customer demands is putting enormous pressure on...
The best way to leverage your CloudEXPO | DXWorldEXPO presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering CloudEXPO | DXWorldEXPO will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at CloudEXPO. Product announcements during our show provide your company with the most reach through our targeted audienc...
JETRO showcased Japan Digital Transformation Pavilion at SYS-CON's 21st International Cloud Expo® at the Santa Clara Convention Center in Santa Clara, CA. The Japan External Trade Organization (JETRO) is a non-profit organization that provides business support services to companies expanding to Japan. With the support of JETRO's dedicated staff, clients can incorporate their business; receive visa, immigration, and HR support; find dedicated office space; identify local government subsidies; get...
DXWorldEXPO LLC announced today that All in Mobile, a mobile app development company from Poland, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. All In Mobile is a mobile app development company from Poland. Since 2014, they maintain passion for developing mobile applications for enterprises and startups worldwide.
@DevOpsSummit at Cloud Expo, taking place November 12-13 in New York City, NY, is co-located with 22nd international CloudEXPO | first international DXWorldEXPO and will feature technical sessions from a rock star conference faculty and the leading industry players in the world.
"Akvelon is a software development company and we also provide consultancy services to folks who are looking to scale or accelerate their engineering roadmaps," explained Jeremiah Mothersell, Marketing Manager at Akvelon, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
As data explodes in quantity, importance and from new sources, the need for managing and protecting data residing across physical, virtual, and cloud environments grow with it. Managing data includes protecting it, indexing and classifying it for true, long-term management, compliance and E-Discovery. Commvault can ensure this with a single pane of glass solution – whether in a private cloud, a Service Provider delivered public cloud or a hybrid cloud environment – across the heterogeneous enter...