Skip to content

Commit

Permalink
ref(profiling) use cleanup instead of destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasBa committed Sep 10, 2024
1 parent d4a2fcd commit 0812b24
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/profiling-node/bindings/cpu_profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,9 @@ class MeasurementsTicker {

size_t listener_count();

~MeasurementsTicker() {
void Cleanup() {
uv_timer_stop(&timer);

auto handle = reinterpret_cast<uv_handle_t *>(&timer);

// Calling uv_close on an inactive handle will cause a segfault.
if (uv_is_active(handle)) {
uv_close(handle, nullptr);
}
uv_close(reinterpret_cast<uv_handle_t *>(&timer), nullptr);
}
};

Expand Down Expand Up @@ -1155,6 +1149,7 @@ void FreeAddonData(napi_env env, void *data, void *hint) {
profiler->cpu_profiler = nullptr;
}

profiler->measurements_ticker.Cleanup();
delete profiler;
}

Expand Down

0 comments on commit 0812b24

Please sign in to comment.