SShortSingh.
Back to feed

How to Diagnose and Fix JavaScript Memory Leaks in Node.js Applications

0
·64 views

Memory leaks in Node.js often manifest as containers running smoothly for roughly 40 minutes before the heap grows steadily, garbage collection intensifies, latency spikes, and the process is killed with OOMKilled. A common misconception is that JavaScript's garbage collector uses reference counting; in reality, V8 uses a mark-and-sweep algorithm that collects any object unreachable from GC roots, making isolated circular references harmless. The V8 heap is generational, and true leaks occur when objects are promoted to old space and never freed, which can be confirmed by monitoring heap size after forced major GC cycles using the --expose-gc flag. If heap usage rises monotonically across multiple samples under steady load, a JavaScript heap leak is confirmed; a stable heap with rising RSS instead points to leaks in native buffers or allocator fragmentation. One of the most frequent causes of leaks in both Node.js and single-page applications is unremoved event listeners, which create strong references from emitters to handlers and everything captured in their scope.

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 ·

GLM-5.4 Has No Public API Price Yet; Coding Plan Sets Effective Cost

Z.ai has not published a per-token API price for GLM-5.4, which remains unavailable pending a security assessment. As of November 24, 2026, the model is accessible only through the GLM Coding Plan, priced at $18, $80, and $168 monthly across three tiers. Usage draws from credit allowances, with GLM-5.4 consuming credits at roughly two-thirds the rate of GLM-5.3, and off-peak hours costing half the standard rate. Because Z.ai publishes its plan prices and credit formula, users can estimate an effective per-token cost on the plan, though any per-million-token figure for the API would be speculation. Plans are non-refundable, so the company's guidance is to begin with monthly billing.

0
ProgrammingDEV Community ·

Choosing Reliable MicroSD Cards for a Raspberry Pi Homelab

MicroSD cards are the standard storage for Raspberry Pi systems, yet they frequently cause downtime in homelab setups. Cards bundled with kits or left in drawers may not withstand the constant writes of a 24/7 service. Failures usually appear gradually, with cards turning read-only, then throwing filesystem errors, and eventually failing to mount. The guide recommends endurance-rated cards, a capacity of 32 to 128 GB with spare headroom, and verifying authenticity with tools like f3 to catch counterfeits. It also suggests benchmarking random write performance, since small random writes are the main load from databases and containers.

0
ProgrammingDEV Community ·

How to test an AI mock interview tool using a role you already know

AI mock interview tools can look convincing in demos, so the article recommends trialing one on a job you already know well. The author suggests defining the role in advance, preparing a list of stories you can stand behind, and using the same setup you would use before a real interview. Key checks include whether follow-up questions respond to what you actually said and whether the feedback targets specific answers rather than generic advice. Reviewing the recording or transcript for accuracy is also advised before acting on any notes. The piece concludes that a tool is worth keeping only if its questions and feedback reflect your own answers.

0
ProgrammingDEV Community ·

Phishing Is a Domain Security Problem, Not Just a User Training Issue

Commentary argues that blaming users for falling for phishing overlooks structural weaknesses in how domains are trusted and displayed. Attackers can exploit lookalike domains and cloned login pages to capture credentials, even when a self-hosted service itself is well patched. The article advises self-hosters to first secure their registrar accounts with authenticator-app two-factor authentication and registrar lock. It then explains how publishing SPF, DKIM, and DMARC DNS records helps stop attackers from spoofing email sent from a domain.