Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

V8 memory usage

what is the minimum RAM required for running v8 java-script engine.

Is it suitable for limited memory devices. I want to use node.js as embedded sever in android application. Is it a good idea?

like image 234
Ranjith Avatar asked Jan 16 '23 03:01

Ranjith


1 Answers

V8 requests memory for the JavaScript heap in 1 MB chunks called pages. These are grouped in spaces which contain different kinds of objects. There are 7 spaces (from, to, pointer, data, code, cell, map), or 8 if you count large object spac. At absolute minimum you need at least one page per space, so that's 7 MB right there. V8 itself is about 3 MB (at least on ARM, YMMV). Plus, you'd need another 2 MB or so for scratch space. So that's 12 MB in total, at minimum. You'd probably want to have 20-30 MB available in total for normal operation.

All this should fit easily on any Android device. All devices I know of have at least 256 MB of RAM, and you can expect the OS and other apps to use at least half of that. Note that the Android web browser already embeds V8 and has no trouble. The browser's instance of V8 likely has a larger memory footprint than the V8 portion of a Node.js server.

like image 54
Jay Conrod Avatar answered Jan 24 '23 11:01

Jay Conrod