MCPcopy Create free account
hub / github.com/Tencent/MMKV / clearMemoryCache

Method clearMemoryCache

Core/MMKV.cpp:335–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333}
334
335void MMKV::clearMemoryCache(bool keepSpace) {
336 SCOPED_LOCK(m_lock);
337 if (m_needLoadFromFile) {
338 return;
339 }
340 MMKVInfo("clearMemoryCache [%s]", m_mmapID.c_str());
341 m_needLoadFromFile = true;
342 m_hasFullWriteback = false;
343
344 clearDictionary(m_dic);
345#ifndef MMKV_DISABLE_CRYPT
346 clearDictionary(m_dicCrypt);
347 if (m_crypter) {
348 if (m_metaInfo->m_version >= MMKVVersionRandomIV) {
349 m_crypter->resetIV(m_metaInfo->m_vector, sizeof(m_metaInfo->m_vector));
350 } else {
351 m_crypter->resetIV();
352 }
353 }
354#endif
355
356 delete m_output;
357 m_output = nullptr;
358
359 if (!keepSpace) {
360 m_file->clearMemoryCache();
361 }
362 // inter-process lock rely on MetaFile's fd, never close it
363 // m_metaFile->clearMemoryCache();
364 m_actualSize = 0;
365 m_metaInfo->m_crcDigest = 0;
366}
367
368void MMKV::close() {
369 MMKVInfo("close [%s]", m_mmapID.c_str());

Callers 15

test_rekeyFunction · 0.95
clearMemoryCacheFunction · 0.45
clearMemoryCacheFunction · 0.45
testReKeyFunction · 0.45
functionalTestFunction · 0.45
clearMemoryCacheFunction · 0.45
clearMemoryCacheFunction · 0.45
onExitMethod · 0.45
checkFileHasDiskErrorMethod · 0.45
clearMemoryCacheFunction · 0.45
ClearMemoryCacheMethod · 0.45

Calls 2

clearDictionaryFunction · 0.85
resetIVMethod · 0.80

Tested by 2

test_rekeyFunction · 0.76
functionalTestFunction · 0.36