~webapps/unity-js-scopes/node.js

« back to all changes in this revision

Viewing changes to lib/v8.js

  • Committer: Marcus Tomlinson
  • Date: 2015-11-13 07:59:04 UTC
  • Revision ID: marcus.tomlinson@canonical.com-20151113075904-h0swczmoq1rvstfc
Node v4 (stable)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) 2014, StrongLoop Inc.
 
2
//
 
3
// Permission to use, copy, modify, and/or distribute this software for any
 
4
// purpose with or without fee is hereby granted, provided that the above
 
5
// copyright notice and this permission notice appear in all copies.
 
6
//
 
7
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 
8
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 
9
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 
10
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 
11
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 
12
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 
13
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
14
 
 
15
'use strict';
 
16
 
 
17
const v8binding = process.binding('v8');
 
18
 
 
19
const heapStatisticsBuffer =
 
20
    new Uint32Array(v8binding.heapStatisticsArrayBuffer);
 
21
 
 
22
const kTotalHeapSizeIndex = v8binding.kTotalHeapSizeIndex;
 
23
const kTotalHeapSizeExecutableIndex = v8binding.kTotalHeapSizeExecutableIndex;
 
24
const kTotalPhysicalSizeIndex = v8binding.kTotalPhysicalSizeIndex;
 
25
const kTotalAvailableSize = v8binding.kTotalAvailableSize;
 
26
const kUsedHeapSizeIndex = v8binding.kUsedHeapSizeIndex;
 
27
const kHeapSizeLimitIndex = v8binding.kHeapSizeLimitIndex;
 
28
 
 
29
exports.getHeapStatistics = function() {
 
30
  const buffer = heapStatisticsBuffer;
 
31
 
 
32
  v8binding.updateHeapStatisticsArrayBuffer();
 
33
 
 
34
  return {
 
35
    'total_heap_size': buffer[kTotalHeapSizeIndex],
 
36
    'total_heap_size_executable': buffer[kTotalHeapSizeExecutableIndex],
 
37
    'total_physical_size': buffer[kTotalPhysicalSizeIndex],
 
38
    'total_available_size': buffer[kTotalAvailableSize],
 
39
    'used_heap_size': buffer[kUsedHeapSizeIndex],
 
40
    'heap_size_limit': buffer[kHeapSizeLimitIndex]
 
41
  };
 
42
};
 
43
 
 
44
exports.setFlagsFromString = v8binding.setFlagsFromString;