Fix HeapProfiler memory leak

Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I7RNIW

Signed-off-by: xwcai98 <xwcai98@gmail.com>
Change-Id: I6eb4d14f1d05b93f51188b9af4fa88b4083818d5
This commit is contained in:
xwcai98 2023-08-09 10:44:06 +08:00
parent abbeed23b7
commit 9a9d72b678
3 changed files with 5 additions and 2 deletions

View File

@ -230,6 +230,9 @@ EcmaVM::~EcmaVM()
initialized_ = false;
#if defined(ECMASCRIPT_SUPPORT_CPUPROFILER)
DFXJSNApi::StopCpuProfilerForFile(this);
#endif
#if defined(ECMASCRIPT_SUPPORT_HEAPPROFILER)
DeleteHeapProfile();
#endif
heap_->WaitAllTasksFinished();
Taskpool::GetCurrentTaskpool()->Destroy(thread_->GetThreadId());

View File

@ -119,7 +119,7 @@ void DFXJSNApi::DumpHeapSnapshot([[maybe_unused]] const EcmaVM *vm, [[maybe_unus
#endif // ECMASCRIPT_SUPPORT_SNAPSHOT
}
void DFXJSNApi::DestroyProfiler([[maybe_unused]] const EcmaVM *vm)
void DFXJSNApi::DestroyHeapProfiler([[maybe_unused]] const EcmaVM *vm)
{
#if defined(ECMASCRIPT_SUPPORT_SNAPSHOT)
ecmascript::HeapProfilerInterface::Destroy(const_cast<EcmaVM *>(vm));

View File

@ -55,7 +55,7 @@ public:
static void DumpHeapSnapshot(const EcmaVM *vm, int dumpFormat, Stream *stream, Progress *progress = nullptr,
bool isVmMode = true, bool isPrivate = false);
static void DumpHeapSnapshot(const EcmaVM *vm, int dumpFormat, bool isVmMode = true, bool isPrivate = false);
static void DestroyProfiler(const EcmaVM *vm);
static void DestroyHeapProfiler(const EcmaVM *vm);
static bool BuildNativeAndJsStackTrace(const EcmaVM *vm, std::string &stackTraceStr);
static bool BuildJsStackTrace(const EcmaVM *vm, std::string &stackTraceStr);