@@ -117,6 +117,7 @@ static bool trace_deprecation = false;
117
117
static bool throw_deprecation = false ;
118
118
static bool abort_on_uncaught_exception = false ;
119
119
static bool trace_sync_io = false ;
120
+ static bool track_heap_objects = false ;
120
121
static const char * eval_string = nullptr ;
121
122
static unsigned int preload_module_count = 0 ;
122
123
static const char ** preload_modules = nullptr ;
@@ -3053,40 +3054,42 @@ static void PrintHelp() {
3053
3054
" iojs debug script.js [arguments] \n "
3054
3055
" \n "
3055
3056
" Options:\n "
3056
- " -v, --version print io.js version\n "
3057
- " -e, --eval script evaluate script\n "
3058
- " -p, --print evaluate script and print result\n "
3059
- " -i, --interactive always enter the REPL even if stdin\n "
3060
- " does not appear to be a terminal\n "
3061
- " -r, --require module to preload (option can be repeated)\n "
3062
- " --no-deprecation silence deprecation warnings\n "
3063
- " --throw-deprecation throw an exception anytime a deprecated "
3057
+ " -v, --version print io.js version\n "
3058
+ " -e, --eval script evaluate script\n "
3059
+ " -p, --print evaluate script and print result\n "
3060
+ " -i, --interactive always enter the REPL even if stdin\n "
3061
+ " does not appear to be a terminal\n "
3062
+ " -r, --require module to preload (option can be repeated)\n "
3063
+ " --no-deprecation silence deprecation warnings\n "
3064
+ " --throw-deprecation throw an exception anytime a deprecated "
3064
3065
" function is used\n "
3065
- " --trace-deprecation show stack traces on deprecations\n "
3066
- " --trace-sync-io show stack trace when use of sync IO\n "
3067
- " is detected after the first tick\n "
3068
- " --v8-options print v8 command line options\n "
3066
+ " --trace-deprecation show stack traces on deprecations\n "
3067
+ " --trace-sync-io show stack trace when use of sync IO\n "
3068
+ " is detected after the first tick\n "
3069
+ " --track-heap-objects track heap object allocations for heap "
3070
+ " snapshots\n "
3071
+ " --v8-options print v8 command line options\n "
3069
3072
#if defined(NODE_HAVE_I18N_SUPPORT)
3070
- " --icu-data-dir=dir set ICU data load path to dir\n "
3071
- " (overrides NODE_ICU_DATA)\n "
3073
+ " --icu-data-dir=dir set ICU data load path to dir\n "
3074
+ " (overrides NODE_ICU_DATA)\n "
3072
3075
#if !defined(NODE_HAVE_SMALL_ICU)
3073
- " Note: linked-in ICU data is\n "
3074
- " present.\n "
3076
+ " Note: linked-in ICU data is\n "
3077
+ " present.\n "
3075
3078
#endif
3076
3079
#endif
3077
3080
" \n "
3078
3081
" Environment variables:\n "
3079
3082
#ifdef _WIN32
3080
- " NODE_PATH ';'-separated list of directories\n "
3083
+ " NODE_PATH ';'-separated list of directories\n "
3081
3084
#else
3082
- " NODE_PATH ':'-separated list of directories\n "
3085
+ " NODE_PATH ':'-separated list of directories\n "
3083
3086
#endif
3084
- " prefixed to the module search path.\n "
3085
- " NODE_DISABLE_COLORS Set to 1 to disable colors in the REPL\n "
3087
+ " prefixed to the module search path.\n "
3088
+ " NODE_DISABLE_COLORS Set to 1 to disable colors in the REPL\n "
3086
3089
#if defined(NODE_HAVE_I18N_SUPPORT)
3087
- " NODE_ICU_DATA Data path for ICU (Intl object) data\n "
3090
+ " NODE_ICU_DATA Data path for ICU (Intl object) data\n "
3088
3091
#if !defined(NODE_HAVE_SMALL_ICU)
3089
- " (will extend linked-in data)\n "
3092
+ " (will extend linked-in data)\n "
3090
3093
#endif
3091
3094
#endif
3092
3095
" \n "
@@ -3187,6 +3190,8 @@ static void ParseArgs(int* argc,
3187
3190
trace_deprecation = true ;
3188
3191
} else if (strcmp (arg, " --trace-sync-io" ) == 0 ) {
3189
3192
trace_sync_io = true ;
3193
+ } else if (strcmp (arg, " --track-heap-objects" ) == 0 ) {
3194
+ track_heap_objects = true ;
3190
3195
} else if (strcmp (arg, " --throw-deprecation" ) == 0 ) {
3191
3196
throw_deprecation = true ;
3192
3197
} else if (strcmp (arg, " --abort-on-uncaught-exception" ) == 0 ||
@@ -3876,7 +3881,11 @@ Environment* CreateEnvironment(Isolate* isolate,
3876
3881
static void StartNodeInstance (void * arg) {
3877
3882
NodeInstanceData* instance_data = static_cast <NodeInstanceData*>(arg);
3878
3883
Isolate* isolate = Isolate::New ();
3879
- // Fetch a reference to the main isolate, so we have a reference to it
3884
+ if (track_heap_objects) {
3885
+ isolate->GetHeapProfiler ()->StartTrackingHeapObjects (true );
3886
+ }
3887
+
3888
+ // Fetch a reference to the main isolate, so we have a reference to it
3880
3889
// even when we need it to access it from another (debugger) thread.
3881
3890
if (instance_data->is_main ())
3882
3891
node_isolate = isolate;
0 commit comments