!887 disable memory cache and delayed free

Merge pull request !887 from 何寅燊/master
This commit is contained in:
openharmony_ci 2024-11-21 10:12:44 +00:00 committed by Gitee
commit 75eee20d19
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 31 additions and 0 deletions

View File

@ -31,6 +31,10 @@
#include "deviceauth_sa.h"
#ifdef DEV_AUTH_USE_JEMALLOC
#include "malloc.h"
#endif
namespace OHOS {
static const uint32_t RESTORE_CODE = 14701;
@ -194,9 +198,18 @@ void DeviceAuthAbility::OnStart()
LOGI("DeviceAuthAbility start success.");
}
static void DevAuthInitMemoryPolicy(void)
{
#ifdef DEV_AUTH_USE_JEMALLOC
(void)mallopt(M_SET_THREAD_CACHE, M_THREAD_CACHE_DISABLE);
(void)mallopt(M_DELAYED_FREE, M_DELAYED_FREE_DISABLE);
#endif
}
int32_t DeviceAuthAbility::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
MessageOption &option)
{
DevAuthInitMemoryPolicy();
std::u16string readToken = data.ReadInterfaceToken();
bool isRestoreCall = ((code == RESTORE_CODE) && (readToken == std::u16string(u"OHOS.Updater.RestoreData")));

View File

@ -33,6 +33,10 @@
#include "hisysevent_adapter.h"
#endif
#ifdef DEV_AUTH_USE_JEMALLOC
#include "malloc.h"
#endif
using namespace std;
namespace OHOS {
static std::mutex g_cBMutex;
@ -272,9 +276,18 @@ int32_t ServiceDevAuth::HandleDeviceAuthCall(uint32_t code, MessageParcel &data,
return 0;
}
static void DevAuthInitMemoryPolicy(void)
{
#ifdef DEV_AUTH_USE_JEMALLOC
(void)mallopt(M_SET_THREAD_CACHE, M_THREAD_CACHE_DISABLE);
(void)mallopt(M_DELAYED_FREE, M_DELAYED_FREE_DISABLE);
#endif
}
int32_t ServiceDevAuth::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
MessageOption &option)
{
DevAuthInitMemoryPolicy();
std::u16string readToken = data.ReadInterfaceToken();
bool isRestoreCall = ((code == RESTORE_CODE) && (readToken == std::u16string(u"OHOS.Updater.RestoreData")));
if (readToken != GetDescriptor() && !isRestoreCall) {

View File

@ -320,6 +320,11 @@ if (os_level == "mini" || os_level == "small") {
if (target_cpu == "arm") {
cflags += [ "-DBINDER_IPC_32BIT" ]
}
if (use_musl) {
if (musl_use_jemalloc && musl_use_jemalloc_dfx_intf) {
defines += [ "DEV_AUTH_USE_JEMALLOC" ]
}
}
include_dirs += [
"${frameworks_path}/inc",