TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

V8 memory quiz

87 pointsby mostlystaticover 7 years ago

5 comments

bakery2kover 7 years ago
Spoiler: V8&#x27;s default array implementation holds pointers to boxed objects [Questions 5 &amp; 6], but there are special-case implementations for arrays of doubles [1] and 16-bit integers [9] (and presumably others). However, adding a single string to an array of doubles violates the special-case and requires every double to be boxed, significantly increasing memory footprint [2].<p>It&#x27;s interesting to compare this to a &quot;NaN-boxing&quot; approach, which allows pointers and doubles (and other simple values) to all exist in a single &quot;namespace&quot; of 8-byte values. In the (uncommon?) case of a heterogeneous array, this can save memory by avoiding the need to box simple values. The downside is that NaN-boxing prevents the use of full 64-bit pointers.
评论 #16251588 未加载
评论 #16251661 未加载
Waterluvianover 7 years ago
This is one of my favourite ways to play with a concept. The quiz part forces my brain to turn on the problem solving section rather than just the reading section.
ameliusover 7 years ago
Okay, but how about other JavaScript engines?<p>And shouldn&#x27;t stuff like this be in the specs, so that the language becomes more consistent and predictable?
评论 #16252039 未加载
评论 #16251842 未加载
评论 #16251832 未加载
aiCeivi9over 7 years ago
So V8 doesn&#x27;t use compressed pointers? It sounds wasteful to use whole 8 bytes for pointer if typical JS application is unlikely to need more than 2GB of ram
mcguireover 7 years ago
The default size of an array for V8 is over 1304209 elements?
评论 #16253005 未加载