How do you detect memory limits in JavaScript?

As a web developer/programmer, I always need to know about the memory limits and memory usage. After some searches I found that it seems that there is no a specific way to know memory usage by a website, or function but I found some codes that helps to know about heap memory limit and memory usage.

The advice of experts is to use max. 50MB in desktop versions and 20MB in mobile.

By writing these codes on chrome console, can have these numbers.

To have Javascript heap size:


and to know how much are you currently using, try this:


for example, in my system, heap size limit is almost 2.18GB


and heap memory usage for an array of simple object in json format with 100K items, takes almost  32MB


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s