as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support

Investigate JavaScript Memory

JavaScript memory exceptions cause app crashes and poor user experience. Exceeding the JavaScript heap limit (200 MB for TV profiles) triggers a Hermes Garbage Collector (HermesGC) out of memory error. Common triggers include memory leaks, large data structures, and inefficient resource cleanup.

This page explains the steps to identify, analyze, and resolve memory issues.

Step 1: Identify the crash reason

  1. From the device, download and open the aggregated crash report (ACR).
  2. In the ACR file, look for CrashReason:SIGSEGV.
  3. To confirm a JavaScript heap memory overflow, check the app logs for HermesGC OOM.

Example ACR:

CrashDescriptor:1b26a2ab4b104aa474b84218e69d2780
CrashLang:Native
Process:com.org.keplerApp
LibraryName:keplerscript-runtime-loader-2.so
CrashReason:SIGSEGV

Example log:

Nov 21 20:10:13.389612 firestick-010bc8cead0041f0 local0.info keplerscript-ru[7087]: 27 I KeplerScript:[Logging.cpp:40] HermesGC OOM: [] reason = Max heap size was exceeded (1 from category: vm_allocate_category), numCollections = 177, heapSize = 205520896, allocated = 201732128, va = 205520896, external = 88.

SIGSEGV with HermesGC OOM log errors indicate JavaScript heap memory issues during runtime.

Step 2: Identify memory leak scenarios

  1. Open Visual Studio (VS) Code.
  2. Start the Memory Monitor.
  3. Track the JavaScript heap graph for 200-MB threshold approaches.

    Memory Monitor graph showing JavaScript heap usage approaching the 200MB threshold limit
    JavaScript heap memory approaching critical 200MB limit
  4. Record a session to capture crash scenarios.

Step 3: Capture JavaScript heap snapshots

  1. Attach Chrome DevTools to your React Native for Vega app. Follow the steps in Start Chrome DevTools.

    Animated demonstration of connecting Chrome DevTools to React Native Vega app for debugging
    Connecting Chrome DevTools to Vega app for memory analysis
  2. Navigate to the Memory tab and select Heap Snapshot.

    Chrome DevTools Memory tab interface with Heap Snapshot option selected and Take snapshot button highlighted
    Chrome DevTools Memory tab for capturing heap snapshots
  3. Click Take snapshot.

    The following image is an example of a heap snapshot.

    Chrome DevTools showing captured heap snapshot with download arrow button for saving snapshot to local machine
    Heap snapshot captured with download option available
  4. To download the snapshot onto your host machine, click the down arrow.

Step 4: Analyze JavaScript heap snapshot

Analyze JavaScript heap snapshots using Memlab or Chrome DevTools.

Analyze with Memlab

  1. Install Memlab:

    Copied to clipboard.

     npm install -g memlab
    
  2. Run the analysis:

    Copied to clipboard.

    memlab find-leaks --baseline <initial-snapshot> --target <post-leak-snapshot> --final <post-clear-snapshot> --trace-all-objects
    

    Memlab compares three heap snapshots:

    • Baseline - The initial state
    • Target - The state after the potential leak
    • Final - The state after cleanup

    --trace-all-objects argument marks all target page objects as potential leaks.

    memlab find-leaks compares the three heap snapshots and provides a summary in a table format:

    Memlab analysis results table showing memory leak comparison between baseline, target, and final snapshots with object counts and sizes
    Memlab analysis table comparing heap snapshots for memory leaks
  3. Find uncleared objects from the table.

  4. Check code for deallocating persistent objects.

  5. Review retainer traces.

    Memlab ranks leaked objects on retained sizes. Use retainer traces to locate leaked objects in the object tree.

    Memlab retainer traces showing detailed object tree hierarchy and memory leak paths with retained sizes
    Memlab retainer traces reveal memory leak object paths

Learn more about Memblab:

Analyze with Chrome DevTools

  1. Open Chrome DevTools and go to the Memory tab.

  2. Upload your JavaScript heap snapshot.

  3. Analyze the JavaScript heap snapshot using different views:

    Chrome DevTools heap snapshot analysis interface showing Summary view with objects sorted by Shallow Size and Retained Size columns
    Chrome DevTools heap snapshot analysis with multiple view options
  • Sort by Shallow Size to find the heaviest objects
  • Sort by Retained Size to identify the most impactful objects

Select different views (Summary, Comparison, Containment, Statistics) for various analysis perspectives.

Learn about snapshots analysis:


Last updated: Sep 30, 2025