DEV Community

Cover image for Javascript Memory Management
ikbal arslan
ikbal arslan

Posted on

1

Javascript Memory Management

When the javascript engine starts executing the code it will store variables inside of the memory. for storing data, runtime uses two different memory:

  • Stack memory
  • Heap memory

Javascript only can communicate with stack memory.

Before explaining the differences around these memories I should explain the data types in javascript. In javascript, we have two different data types:

  • Primitive types: primitive types stored directly in the stack
    • String, Number, Boolean, Null, Undefined, Symbol, BigInt

  • Reference types: Stored in the heap and accessed by reference from Stack
    • Arrays, Functions, Objects

Image description


For maximum optimization in the memory space javascript engine uses something called garbage collector. it will clean the value immediately when a value is not reachable via a variable(label).

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (1)

Collapse
 
martinfjant profile image
Martin Falk Johansson

What is the purpose of this? Is it unfinished?

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more