v8

Node.js heap memory limit for single object

本小妞迷上赌 提交于 2019-12-17 19:36:25
问题 Does v8 have limits on the heap allocations for single objects? a = new Array(1024*1024*102) fails on node command-line with FATAL ERROR: JS Allocation failed - process out of memory Also, this fails with the same error when run as a script node --expose-gc --nouse-idle-notification --max-old-space-size=8192 FATAL ERROR: CALL_AND_RETRY_0 Allocation failed - process out of memory var util = require('util'); o = {}; while(1) { o["hahahahahaha" + String(ctr)] = ctr; ctr++; if (ctr % 100000 === 0

What are the differences between Long Term Support (LTS) and Stable versions of Node.js?

点点圈 提交于 2019-12-17 17:38:06
问题 Originally asked: What is the difference between Node.js 4.x branch with LTS (Long Term Support) and the 5.x branch (listed as Stable)? But this is equally relevant to understanding the difference between 6.x and 7.x and, in the future, 8.x and 9.x Generally, I always lean towards the latest version for features and performance (as I now do a lot of ES6 / ES7). Is there any information on how production ready the "stable" branches are? 回答1: To understand the difference you need to understand

How to get a microtime in Node.js?

感情迁移 提交于 2019-12-17 17:36:12
问题 How can I get the most accurate time stamp in Node.js? ps My version of Node.js is 0.8.X and the node-microtime extension doesn't work for me (crash on install) 回答1: new Date().getTime() ? This gives you a timestamp in milliseconds, which is the most accurate that JS will give you. Update: As stated by vaughan, process.hrtime() is available within Node.js - its resolution are nanoseconds and therefore its much higher, also this doesn't mean it has to be more exact. PS.: Just to be clearer,

Embed a JavaScript engine in an iOS application

余生长醉 提交于 2019-12-17 17:24:32
问题 I wonder if anyone has successfully ported a javascript engine/interpreter to iOS. I'm writing an iPhone game that I would like to use Javascript as the high-level scripting language (AI, gameplay, etc.), but to do that, I need to compile the JS engine into a static library and link it against my objectiveC program for iPhone OS. There are some candidate JS engine I'm looking at but I couldn't find any successful cases for doing that. Here're the js engine I was hoping to use for iOS google's

How does Bluebird's util.toFastProperties function make an object's properties “fast”?

北战南征 提交于 2019-12-17 17:23:34
问题 In Bluebird's util.js file, it has the following function: function toFastProperties(obj) { /*jshint -W027*/ function f() {} f.prototype = obj; ASSERT("%HasFastProperties", true, obj); return f; eval(obj); } For some reason, there's a statement after the return function, which I'm not sure why it's there. As well, it seems that it is deliberate, as the author had silenced the JSHint warning about this: Unreachable 'eval' after 'return'. (W027) What exactly does this function do? Does util

Use V8 JavaScript engine to execute JS lib without web view

北战南征 提交于 2019-12-17 15:44:46
问题 I am developing a JavaScript component which is responsible for making requests to the server and dispatching results to the UI. By doing this in JavaScript, I am able to use my component in several types of UI: Android app, iOS app, desktop app (QT), web app... All these UI have instantiated a web view, so my component is started when the UI loads the dedicated URL ( webview.load("file://myfirstWebPage.html") ). This first web page loads all the JavaScript components, and when it's done, the

`gem install therubyracer` fails on Mac OS X Lion

核能气质少年 提交于 2019-12-17 15:19:20
问题 I would appreciate some help in getting gem install therubyracer to work. Here is the error: $ gem install therubyracer Building native extensions. This could take a while... ERROR: Error installing therubyracer: ERROR: Failed to build gem native extension. /Users/david/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb checking for main() in -lobjc... yes *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf

How does setInterval and setTimeout work?

懵懂的女人 提交于 2019-12-17 10:25:49
问题 I was in an awkward situation , I am working with pure JavaScript for almost 3 years, and I know that JavaScript is single-threaded language, and that you can simulate asynchronous execution using setInterval and setTimeout functions, but when I thought about how they can work I couldn't clearly understand it. So how these functions affect execution context? I suppose that in specific time runs only one part of the code and after it switches to another part. If so, then would a lot of

How can % signs be used in identifiers

本秂侑毒 提交于 2019-12-17 07:48:43
问题 Browsing the v8 tree, under the src directory, some js files were there, providing some basic JS objects like Math, Array etc. Browsing those files, I saw identifiers including a percent sign (%) in their names, i.e. %Foo . I first naively thought it was some other allowed character in JS's identifiers, but when I tried it in shell, it yelled at me, saying that I'm violating syntax rules. But if it is a syntax error, how come d8 works? Here are an example from the actual source code: src

Unknown events in nodejs/v8 flamegraph using perf_events

拜拜、爱过 提交于 2019-12-17 04:02:17
问题 I try to do some nodejs profiling using Linux perf_events as described by Brendan Gregg here. Workflow is following: run node >0.11.13 with --perf-basic-prof , which creates /tmp/perf-(PID).map file where JavaScript symbol mapping are written. Capture stacks using perf record -F 99 -p `pgrep -n node` -g -- sleep 30 Fold stacks using stackcollapse-perf.pl script from this repository Generate svg flame graph using flamegraph.pl script I get following result (which look really nice at the