Sitemap
Stackademic

Stackademic is a learning hub for programmers, devs, coders, and engineers. Our goal is to democratize free coding education for the world.

Member-only story

Mastering Memory Efficiency in JavaScript

--

Press enter or click to view image in full size

Have you ever experienced huge memory usage in your web application?

it consumes your memory device and prevents you from multitasking. Most of us are striving to make the most efficient and performant software. One of the things that we ought to handle is memory management. Memory is a crucial aspect that we always need to take care of and improve at any chance so we can improve the user experience and widen the accessibility of the software.

Lately, I have found an interesting collection type in JavaScript. I was trying to implement this and I will show you my experiment using this one.

WeakMap

yup this one, according to mdn web docs, weakmap is a collection of key/value pairs whose keys must be objects or non-registered symbols with values of any arbitrary Javascript type. You can read more in this article

Since the keys of WeakMap are weakly referenced, they can be garbage collected automatically. It will be cleaning up memory faster and remove the memory block.

As we know, javascript garbage collector automatically processes to clean up the memory, but I think if you handle a huge of data; you can consider having a good strategy for how we manage our memory.

--

--

Rully Saputra
Rully Saputra

Written by Rully Saputra

Frontend engineer level II at Tiket.com | Technical Mentor | Javascript instructor | 5+ of hands-on experience in software engineering

Stackademic
Stackademic

Published in Stackademic

Stackademic is a learning hub for programmers, devs, coders, and engineers. Our goal is to democratize free coding education for the world.