Browse Source

src: use Number::New() for heapTotal/heapUsed

With --max_old_space_size=12345 it's possible to create a JS heap that
is larger than what fits in an unsigned int so use Number::New() rather
than Integer::NewFromUnsigned().

Performance-wise, it doesn't matter much.  If V8 can fit the double in
a SMI, it will.

PR-URL: https://github.com/iojs/io.js/pull/1148
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
v1.8.0-commit
Ben Noordhuis 10 years ago
parent
commit
2551c1d2ca
  1. 8
      src/node.cc

8
src/node.cc

@ -1932,10 +1932,10 @@ void MemoryUsage(const FunctionCallbackInfo<Value>& args) {
HeapStatistics v8_heap_stats; HeapStatistics v8_heap_stats;
env->isolate()->GetHeapStatistics(&v8_heap_stats); env->isolate()->GetHeapStatistics(&v8_heap_stats);
Local<Integer> heap_total = Local<Number> heap_total =
Integer::NewFromUnsigned(env->isolate(), v8_heap_stats.total_heap_size()); Number::New(env->isolate(), v8_heap_stats.total_heap_size());
Local<Integer> heap_used = Local<Number> heap_used =
Integer::NewFromUnsigned(env->isolate(), v8_heap_stats.used_heap_size()); Number::New(env->isolate(), v8_heap_stats.used_heap_size());
Local<Object> info = Object::New(env->isolate()); Local<Object> info = Object::New(env->isolate());
info->Set(env->rss_string(), Number::New(env->isolate(), rss)); info->Set(env->rss_string(), Number::New(env->isolate(), rss));

Loading…
Cancel
Save