Summary 

Currently, --max-old-space-size requires a fixed memory value in MB. 
However, in containerized environments (e.g., Docker, Kubernetes), 
available memory can vary dynamically. Introducing a percentage-based 
option would allow Node.js to adjust its memory usage relative to total 
system memory, reducing the risk of OOMKills while optimizing performance.
Why is this needed? 
   
   - *Improves compatibility* with containerized environments where memory 
   limits are dynamic. 
   - *Prevents over-allocation & OOMKills* when memory limits change. 
   - *Simplifies memory management*, eliminating the need for external 
   scripts to compute heap size dynamically. 

Proposed Solution 

Introduce a new syntax for --max-old-space-size, allowing it to accept a 
percentage of total system memory, e.g.:
node --max-old-space-size=80% app.js 

*Example Behavior:*

   - On a system with *4GB RAM*, --max-old-space-size=80% would set it to 
   *3.2GB*. 
   - On a system with *1GB RAM*, it would set it to *800MB*. 

Alternatives Considered 
   
   - Manually setting a fixed value, which requires prior knowledge of 
   system memory. 
   - Using external scripts (os.totalmem()) to calculate heap size 
   dynamically. 

Request for Guidance 

I’m new to contributing to V8 and would appreciate any guidance on the best 
way to approach this change. Specifically:

   - Are there existing discussions or work related to this idea? 
   - Which parts of the V8 codebase should I explore for implementing this? 
   - Any recommended best practices or similar features I should reference? 

Looking forward to your feedback and help! šŸš€

-- 
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/v8-dev/e44b0fcd-35a2-4d81-84df-a2fecdabd33en%40googlegroups.com.

Reply via email to