SShortSingh.
Back to feed

How JavaScript Manages Memory and How Developers Can Optimize It

0
·2 views

JavaScript automatically allocates memory when variables, objects, or functions are created, and uses a garbage collection strategy called mark-and-sweep to free memory that is no longer referenced. Despite this automation, developers can inadvertently cause memory leaks through global variables, uncleaned event listeners, poorly managed closures, and detached DOM elements. Best practices to prevent leaks include using let and const for tight scoping, removing event listeners and clearing intervals when no longer needed, and explicitly setting large objects to null after use. WeakMap and WeakSet are recommended for cases where objects should be garbage-collected once they have no other references. Modern browser tools such as Chrome DevTools' Memory Panel and heap profiling can help developers identify and resolve persistent memory issues in their applications.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

New npm tool anchors proof-of-work solves to Bitcoin for tamper-proof auditing

A developer has released @powforge/solve-witness, an npm package that makes server-side proof-of-work solve events independently verifiable without relying on server logs. The tool batches accepted solves into a Merkle tree every 10 minutes, sealing them into a single 32-byte root hash that is then submitted to an OpenTimestamps calendar and anchored to the Bitcoin blockchain. Because all solves within a window share one Bitcoin timestamp, the on-chain cost remains constant regardless of how many solves occurred, making the approach economically efficient at scale. Anyone can later verify a specific solve by tracing a leaf hash through a Merkle inclusion path to the timestamped root, using standard SHA-256 and the reference OpenTimestamps tooling — no trust in the originating server required. The package is designed to integrate directly with the @powforge/ratelimit middleware via an onSolve hook.

0
ProgrammingDEV Community ·

HPE Juniper Solution Promises 319% ROI by Unifying AI Data Center Networks

Hewlett Packard Enterprise (HPE) is promoting its Juniper AI data center solution as a way to help IT teams transition from fragmented, siloed infrastructure to a unified, open networking platform. The solution targets a core challenge facing organizations scaling AI workloads: reliance on proprietary hardware ecosystems that limit flexibility and drive up costs. Central to the offering is Marvis, a virtual network assistant designed to autonomously detect and resolve network issues, replacing manual troubleshooting processes. HPE claims the platform delivers a 104% improvement in operational speed and a 319% return on investment. The company positions the solution as an end-to-end secure, open Ethernet environment built specifically for the demands of AI training and inference at scale.

0
ProgrammingDEV Community ·

Researchers Run Privacy-Preserving GNN Inference Across Three Microcontrollers

An independent researcher has been exploring whether Graph Neural Networks (GNNs) can perform inference on traffic data across three microcontrollers without any single device ever accessing plaintext inputs, model weights, or intermediate values. The approach uses Replicated Secret Sharing (RSS) in a three-party semi-honest setting, where each data value is split into shares so no individual party can reconstruct the original. A key insight reduces communication overhead: since road intersection topology is public knowledge, the adjacency matrix multiplication requires zero inter-device communication, cutting total rounds from five or more down to three per two-layer GCN. The target hardware is ESP32-S3 microcontrollers, making the system relevant for resource-constrained, real-world deployments. The work addresses a practical privacy concern in multi-agency traffic coordination, where sharing raw sensor data could expose movement patterns or individual vehicle trajectories.

0
ProgrammingDEV Community ·

Researcher Tests If Robot Actions Can Be Predicted From Microcontroller Timing Alone

An independent researcher is investigating whether timing side-channel attacks can reveal the actions of multi-agent reinforcement learning (MARL) policies deployed on edge hardware. The study focuses on an ESP32-S3 microcontroller running small neural network policies, where an attacker measures only inference duration and network packet timing without access to inputs, weights, or activations. Experiments span three environments: a custom cooperative grid navigation task, the classic CartPole benchmark, and the PettingZoo MPE Simple Spread scenario. Policies trained via PPO are exported to TFLite and flashed onto the microcontroller, with a custom pipeline used to collect and quantify timing leakage. The research highlights a potential security risk for edge-deployed autonomous systems such as drones, warehouse robots, and IoT networks, where physical proximity could allow adversaries to exploit such timing signals.