trigger gc for l2 device with kill signal

Signed-off-by: lukai <lukai25@huawei.com>
This commit is contained in:
lukai 2021-09-16 19:50:46 +08:00
parent 21d9600da4
commit 122e992d8d
4 changed files with 23 additions and 2 deletions

View File

@ -504,6 +504,25 @@ bool AceContainer::Dump(const std::vector<std::string>& params)
return false;
}
void AceContainer::TriggerGarbageCollection()
{
#if !defined(OHOS_PLATFORM) || !defined(ENABLE_NATIVE_VIEW)
// GPU and IO thread is standalone while disable native view
taskExecutor_->PostTask([] { PurgeMallocCache(); }, TaskExecutor::TaskType::GPU);
taskExecutor_->PostTask([] { PurgeMallocCache(); }, TaskExecutor::TaskType::IO);
#endif
taskExecutor_->PostTask([] { PurgeMallocCache(); }, TaskExecutor::TaskType::UI);
taskExecutor_->PostTask(
[frontend = WeakPtr<Frontend>(frontend_)] {
auto sp = frontend.Upgrade();
if (sp) {
sp->TriggerGarbageCollection();
}
PurgeMallocCache();
},
TaskExecutor::TaskType::JS);
}
void AceContainer::AddAssetPath(
int32_t instanceId, const std::string& packagePath, const std::vector<std::string>& paths)
{

View File

@ -117,6 +117,8 @@ public:
bool Dump(const std::vector<std::string>& params) override;
void TriggerGarbageCollection() override;
void OnFinish()
{
if (platformEventCallback_) {

View File

@ -113,7 +113,7 @@ void ArkJSRuntime::RunGC()
{
JSExecutionScope executionScope(vm_);
LocalScope scope(vm_);
JSNApi::TriggerGC(vm_);
JSNApi::TriggerGC(vm_, JSNApi::TRIGGER_GC_TYPE::COMPRESS_FULL_GC);
}
shared_ptr<JsValue> ArkJSRuntime::NewInt32(int32_t value)

View File

@ -114,7 +114,7 @@ void ArkJSRuntime::RunGC()
{
JSExecutionScope executionScope(vm_);
LocalScope scope(vm_);
JSNApi::TriggerGC(vm_);
JSNApi::TriggerGC(vm_, JSNApi::TRIGGER_GC_TYPE::COMPRESS_FULL_GC);
}
shared_ptr<JsValue> ArkJSRuntime::NewInt32(int32_t value)