MemLab: Automating Memory Leak Detection and Heap Analysis

This ad is not shown to multipass and full ticket holders
React Summit US
React Summit US 2026
November 17 - 20, 2026
New York, US & Online
Upcoming event
React Summit US 2026
React Summit US 2026
November 17 - 20, 2026. New York, US & Online
Bookmark
Rate this content
Sentry
Promoted
Code breaks, fix it faster

Crashes, slowdowns, regressions in prod. Seer by Sentry unifies traces, replays, errors, profiles to find root causes fast.

Get started

Memory leaks in single-page applications are often viewed as mere technical debt, but data shows they directly degrade user experience and engagement. In this talk, we introduce MemLab, an automated framework that identifies memory leaks by simulating user interactions and analyzing heap snapshots.

This talk has been presented at Web Engineering Summit 2026, check out the latest edition of this Tech Conference.

Liang Gong
Liang Gong
19 min
15 Jun, 2026

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Liang introduces MemoryLab, a tool for automating JavaScript memory leak detection. MemoryLab aims to make memory debugging more accessible and scalable by automating the process and utilizing a three snapshot differentiation approach. It clusters similar leak traces to reduce debugging overload and presents representative cluster retainer traces for each memory leak cluster. MemoryLab integrates AI coding tools for memory detection, analysis, and debugging, with the MCP server enabling accurate investigation of memory leaks in heap snapshots.

1. MemoryLab Introduction and Memory Detection

Short description:

Liang introduces MemoryLab, a tool for automating JavaScript memory leak detection. MemoryLab aims to make memory debugging more accessible and scalable by automating the process and utilizing a three snapshot differentiation approach. It tracks allocated objects in different routes to identify memory leaks and uses domain-specific rules to filter the superset for real memory leaks.

Hi, everyone. My name is Liang. I work in the Meta, focusing on web application infrastructure and performance. Today I'll give an introduction to MemoryLab, a tool I built and open sourced to automate JavaScript memory leak detection and heap analysis. At Meta, larger scale A-B web application has shown that increases in client-side memory usage can significantly impact a web app's speed, responsiveness, crash rate, user engagement, and in some cases, even revenue. MemoryLab is an open-source framework from Meta that automates memory detection for JavaScript applications. It also exposes a powerful API for traversing heap snapshots, so you can build custom analysis tailored to your app. Out of the box, it shifts with CLI tools that test common memory and anti-patterns, and help you debug issues quickly.

And more recently, we have been pushing into AI-assisted workflows with the MCP server that lets tools like Cloud Code reason directly over heap graphs. So, the goal here is simple. Take memory debugging from a manual expert-heavy process to something automated, scalable, and much more accessible. To go deeper into each part, I'll start with automating memory detection. We first need to figure out what's a memory leak. Memory leak is essentially a subset chunk of memory that has been allocated, and it was supposed to be released at some point, but somehow it wasn't. So, the broader class of these leaks can be detected using a three snapshot differentiation approach. MemoryLab automates the process.

To better illustrate the idea, here I'll use some animations. Suppose we want to find memory leaks in route B of a real application. MemoryLab starts by visiting a different route, for example, route A, and keeps track of all objects allocated in route A, then navigates the browser to the target route B where we want to find memory leaks. During the navigation, some objects from route A are deallocated, and some new objects are allocated in route B. Finally, MemoryLab navigates away from the target route B. It can either navigate to a different route, for example, route C, or it can go back to route A again. Now, some of those objects creating route B will be deallocated, but some will remain alive. And of course, route C will create some new objects, but in this example we don't really care since we want to find memory leaks introduced in route B. And as highlighted in the orange section of the slides, the interesting part is the objects allocated in target route B but still remains alive even after we navigate away from it. So we have reduced the search space, but still this is a superset of memory leaks. To get real memory leaks, we use some domain-specific rules to filter the superset. For example, most of the red fiber nodes allocated from a page should be deallocated after a few cleanup navigations. So MemoryLab identifies all fiber nodes and detached DOM elements from the superset. We further filter the list by looking for fiber nodes that keep detached DOM elements alive.

2. MemoryLab Heap Traversal and Leak Debugging

Short description:

MemoryLab automates heap traversal and generates actionable reports for memory leak debugging. It decodes heap snapshots, searches for paths to the garbage collector route, and presents reference chains for leaked objects. The tool uses heuristics to balance trace searching for developer understanding and efficiency, aiming to simplify the identification of root causes for memory leaks. MemoryLab clusters similar leak traces to reduce debugging overload and presents representative cluster retainer traces for each memory leak cluster.

So after refining the list by incorporating the domain-specific knowledge, we get a list of leaked objects. Now the memory detection is done, the final step is to ease the memory debugging process by generating actionable reports. MemoryLab automatically traverses the heap and generates reports that explain why the object is still kept alive in memory. It does so by showing a reference chain from the garbage collector route to these leaked objects. Under the hood, MemoryLab decodes and scans the job to heap snapshots. From the leaked objects, MemoryLab searches for a reasonable path to garbage collector route following certain predefined rules to make the retainer trees readable and actionable.

The retainer trees are reference chains from GC route to the leaked object, and this graph here is a simplistic view of the GSHeap. In reality, a heap snapshot usually contains millions of heap objects and tens of millions of references among those heap objects. These snapshots can expose the VM internal optimization metadata and implementation-specific references that are invisible to JavaScript code. These edges may look like retainers, but they are not necessarily developer-created references or real application leak. So we use Heuristic to tune the trace searching algorithm so the trace is balanced between being short while being reasonable to the developers.

And the user can follow the reference chain step-by-step and figure out why those leaked objects are still kept alive in memory. Very often, a single run can detect thousands of leaked objects, but those leaks are almost always caused by no more than a few bugs or root causes. It will be overwhelming to show thousands of leak traces to users. Ideally, we only want to show one representative leak trace from each root cause. For example, here are three leak traces caused by the same bug. As you can see here, the reference chain looks more or less the same, each with a little bit variation. So, how do we put similar leak traces together? This is where leak trace clustering could be a massive help.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Building Better Websites with Remix
React Summit Remote Edition 2021React Summit Remote Edition 2021
33 min
Building Better Websites with Remix
Top Content
Remix is a web framework built on React Router that focuses on web fundamentals, accessibility, performance, and flexibility. It delivers real HTML and SEO benefits, and allows for automatic updating of meta tags and styles. It provides features like login functionality, session management, and error handling. Remix is a server-rendered framework that can enhance sites with JavaScript but doesn't require it for basic functionality. It aims to create quality HTML-driven documents and is flexible for use with different web technologies and stacks.
Speeding Up Your React App With Less JavaScript
React Summit 2023React Summit 2023
32 min
Speeding Up Your React App With Less JavaScript
Top Content
Mishko, the creator of Angular and AngularJS, discusses the challenges of website performance and JavaScript hydration. He explains the differences between client-side and server-side rendering and introduces Quik as a solution for efficient component hydration. Mishko demonstrates examples of state management and intercommunication using Quik. He highlights the performance benefits of using Quik with React and emphasizes the importance of reducing JavaScript size for better performance. Finally, he mentions the use of QUIC in both MPA and SPA applications for improved startup performance.
Full Stack Documentation
JSNation 2022JSNation 2022
28 min
Full Stack Documentation
Top Content
The Talk discusses the shift to full-stack frameworks and the challenges of full-stack documentation. It highlights the power of interactive tutorials and the importance of user testing in software development. The Talk also introduces learn.svelte.dev, a platform for learning full-stack tools, and discusses the roadmap for SvelteKit and its documentation.
SolidJS: Why All the Suspense?
JSNation 2023JSNation 2023
28 min
SolidJS: Why All the Suspense?
Top Content
Suspense is a mechanism for orchestrating asynchronous state changes in JavaScript frameworks. It ensures async consistency in UIs and helps avoid trust erosion and inconsistencies. Suspense boundaries are used to hoist data fetching and create consistency zones based on the user interface. They can handle loading states of multiple resources and control state loading in applications. Suspense can be used for transitions, providing a smoother user experience and allowing prioritization of important content.
Tanstack Start - A Client-Side First Full-Stack React Framework
React Summit US 2024React Summit US 2024
30 min
Tanstack Start - A Client-Side First Full-Stack React Framework
Top Content
We surveyed thousands of developers to show that a louder audience leads to a better presentation. There has been a shift in web app development towards server-first architectures, which has improved full-stack capabilities but at the cost of complexity and divergence from the client-centric approach. Tanstec Start is a meta-framework that aims to provide the best client-side authoring experience with powerful server-side primitives. The Tansec Router supports advanced routing features, URL state management, and JSON storage. Combined with the server-side rendering capabilities of TanStack Start, it becomes even more powerful. The TanStack Router has isomorphic loaders and integrates seamlessly with TanStack Query for additional features like polling and offline support. UseSuspenseQuery allows for dynamic streaming of data during SSR. TanStack Start also offers server-side features, API routes, server functions, and middleware. The future plans include RSCs, websockets, real-time primitives, and static pre-rendering. TanStack Start is now in beta and is suitable for building React apps. It is open source.
From GraphQL Zero to GraphQL Hero with RedwoodJS
GraphQL Galaxy 2021GraphQL Galaxy 2021
32 min
From GraphQL Zero to GraphQL Hero with RedwoodJS
Top Content
Tom Pressenwurter introduces Redwood.js, a full stack app framework for building GraphQL APIs easily and maintainably. He demonstrates a Redwood.js application with a React-based front end and a Node.js API. Redwood.js offers a simplified folder structure and schema for organizing the application. It provides easy data manipulation and CRUD operations through GraphQL functions. Redwood.js allows for easy implementation of new queries and directives, including authentication and limiting access to data. It is a stable and production-ready framework that integrates well with other front-end technologies.

Workshops on related topic

Building WebApps That Light Up the Internet with QwikCity
JSNation 2023JSNation 2023
170 min
Building WebApps That Light Up the Internet with QwikCity
WorkshopFree
Miško Hevery
Miško Hevery
Building instant-on web applications at scale have been elusive. Real-world sites need tracking, analytics, and complex user interfaces and interactions. We always start with the best intentions but end up with a less-than-ideal site.
QwikCity is a new meta-framework that allows you to build large-scale applications with constant startup-up performance. We will look at how to build a QwikCity application and what makes it unique. The workshop will show you how to set up a QwikCitp project. How routing works with layout. The demo application will fetch data and present it to the user in an editable form. And finally, how one can use authentication. All of the basic parts for any large-scale applications.
Along the way, we will also look at what makes Qwik unique, and how resumability enables constant startup performance no matter the application complexity.
Back to the Roots With Remix
React Summit 2023React Summit 2023
106 min
Back to the Roots With Remix
Workshop
Alex Korzhikov
Pavlik Kiselev
2 authors
The modern web would be different without rich client-side applications supported by powerful frameworks: React, Angular, Vue, Lit, and many others. These frameworks rely on client-side JavaScript, which is their core. However, there are other approaches to rendering. One of them (quite old, by the way) is server-side rendering entirely without JavaScript. Let's find out if this is a good idea and how Remix can help us with it?
Prerequisites- Good understanding of JavaScript or TypeScript- It would help to have experience with React, Redux, Node.js and writing FrontEnd and BackEnd applications- Preinstall Node.js, npm- We prefer to use VSCode, but also cloud IDEs such as codesandbox (other IDEs are also ok)
Let AI Be Your Docs
JSNation 2024JSNation 2024
69 min
Let AI Be Your Docs
Workshop
Jesse Hall
Jesse Hall
Join our dynamic workshop to craft an AI-powered documentation portal. Learn to integrate OpenAI's ChatGPT with Next.js 14, Tailwind CSS, and cutting-edge tech to deliver instant code solutions and summaries. This hands-on session will equip you with the knowledge to revolutionize how users interact with documentation, turning tedious searches into efficient, intelligent discovery.
Key Takeaways:
- Practical experience in creating an AI-driven documentation site.- Understanding the integration of AI into user experiences.- Hands-on skills with the latest web development technologies.- Strategies for deploying and maintaining intelligent documentation resources.
Table of contents:- Introduction to AI in Documentation- Setting Up the Environment- Building the Documentation Structure- Integrating ChatGPT for Interactive Docs
Learn Fastify One Plugin at a Time
Node Congress 2021Node Congress 2021
128 min
Learn Fastify One Plugin at a Time
Workshop
Matteo Collina
Matteo Collina
Fastify is an HTTP framework for Node.js that focuses on providing a good developer experience without compromising on performance metrics. What makes Fastify special are not its technical details, but its community which is wide open for contributions of any kind. Part of the secret sauce is Fastify plugin architecture that enabled developers to write more than a hundred plugins.This hands-on workshop is structured around a series of exercises that covers from basics "hello world", to how to structure a project, perform database access and authentication.

https://github.com/nearform/the-fastify-workshop
Build a Product Page with Shopify’s Hydrogen Framework
React Advanced 2022React Advanced 2022
81 min
Build a Product Page with Shopify’s Hydrogen Framework
Workshop
David Witt
David Witt
Get hands on with Hydrogen, a React-based framework for building headless storefronts. Hydrogen is built for Shopify commerce with all the features you need for a production-ready storefront. It provides a quick start, build-fast environment so you can focus on the fun stuff - building unique commerce experiences. In this workshop we’ll scaffold a new storefront and rapidly build a product page. We’ll cover how to get started, file-based routing, fetching data from the Storefront API, Hydrogen’s built-in components and how to apply styling with Tailwind.You will know:- Get started with the hello-world template on StackBlitz- File-based routing to create a /products/example route- Dynamic routing /products/:handle- Hit the Storefront API with GraphQL- Move the query into the Hydrogen app- Update the query to fetch a product by handle- Display title, price, image & description.- Tailwind styling- Variant picker and buy now button- Bonus if there’s time: Collections page
Prerequisites: - A Chromium-based browser (StackBlitz)- Ideally experience with React. A general web development background would be fine.
Build a Universal Reactive Data Library with Starbeam
JSNation 2023JSNation 2023
66 min
Build a Universal Reactive Data Library with Starbeam
WorkshopFree
Yehuda Katz
Yehuda Katz
This session will focus on Starbeam's universal building blocks. We'll use Starbeam to build a data library that works in multiple frameworks.We'll write a library that caches and updates data, and supports relationships, sorting and filtering.Rather than fetching data directly, it will work with asynchronously fetched data, including data fetched after initial render. Data fetched and updated through web sockets will also work well.All of these features will be reactive, of course.Imagine you filter your data by its title, and then you update the title of a record to match the filter: any output relying on the filtered data will update to reflect the updated filter.In 90 minutes, you'll build an awesome reactive data library and learn a powerful new tool for building reactive systems. The best part: the library works in any framework, even though you don't think about (or depend on) any framework when you built it.
Table of contents- Storing a Fetched Record in a Cell- Storing multiple records in a reactive Map- Reactive iteration is normal iteration- Reactive filtering is normal filtering- Fetching more records and updating the Map- Reactive sorting is normal sorting (is this getting a bit repetitive?)- Modelling cache invalidation as data- Bonus: reactive relationships