@@ -76,7 +76,8 @@ class MeasurementsTicker {
76
76
MeasurementsTicker (uv_loop_t *loop)
77
77
: period_ms(100 ), isolate(v8::Isolate::GetCurrent()) {
78
78
uv_timer_init (loop, &timer);
79
- timer.data = this ;
79
+ uv_handle_set_data (reinterpret_cast <uv_handle_t *>(&timer), this );
80
+ uv_unref (reinterpret_cast <uv_handle_t *>(&timer));
80
81
}
81
82
82
83
static void ticker (uv_timer_t *);
@@ -196,6 +197,10 @@ void MeasurementsTicker::cpu_callback() {
196
197
};
197
198
198
199
void MeasurementsTicker::ticker (uv_timer_t *handle) {
200
+ if (handle == nullptr ) {
201
+ return ;
202
+ }
203
+
199
204
MeasurementsTicker *self = static_cast <MeasurementsTicker *>(handle->data );
200
205
self->heap_callback ();
201
206
self->cpu_callback ();
@@ -323,18 +328,6 @@ void SentryProfile::Start(Profiler *profiler) {
323
328
status = ProfileStatus::kStarted ;
324
329
}
325
330
326
- static void CleanupSentryProfile (Profiler *profiler,
327
- SentryProfile *sentry_profile,
328
- const std::string &profile_id) {
329
- if (sentry_profile == nullptr ) {
330
- return ;
331
- }
332
-
333
- sentry_profile->Stop (profiler);
334
- profiler->active_profiles .erase (profile_id);
335
- delete sentry_profile;
336
- };
337
-
338
331
v8::CpuProfile *SentryProfile::Stop (Profiler *profiler) {
339
332
// Stop the CPU Profiler
340
333
v8::CpuProfile *profile = profiler->cpu_profiler ->StopProfiling (
@@ -376,6 +369,18 @@ const uint16_t &SentryProfile::cpu_usage_write_index() const {
376
369
return cpu_write_index;
377
370
};
378
371
372
+ static void CleanupSentryProfile (Profiler *profiler,
373
+ SentryProfile *sentry_profile,
374
+ const std::string &profile_id) {
375
+ if (sentry_profile == nullptr ) {
376
+ return ;
377
+ }
378
+
379
+ sentry_profile->Stop (profiler);
380
+ profiler->active_profiles .erase (profile_id);
381
+ delete sentry_profile;
382
+ };
383
+
379
384
#ifdef _WIN32
380
385
static const char kPlatformSeparator = ' \\ ' ;
381
386
static const char kWinDiskPrefix = ' :' ;
@@ -1049,6 +1054,7 @@ void FreeAddonData(napi_env env, void *data, void *hint) {
1049
1054
1050
1055
if (profiler->cpu_profiler != nullptr ) {
1051
1056
profiler->cpu_profiler ->Dispose ();
1057
+ profiler->cpu_profiler = nullptr ;
1052
1058
}
1053
1059
1054
1060
delete profiler;
0 commit comments