Comments (26)
It's possible. It's not about how many items you store, but how big your items are.
from mmkv.
Should actualSize equals file size?
from mmkv.
No.
from mmkv.
And I don't recommend storing big data inside MMKV, at lease not in current release.
Checkout the FAQ for more information.
from mmkv.
Thank you. We didn't stored big date.
I check the big mmkv file with hex friend, only first 4M is valid data, remaining 130M is "0".
from mmkv.
That's weird. Can you send a reproducible demo project to me? [email protected]
from mmkv.
I don't know the reproduce step, I got the file from online gray version.
The first line is like this, the actual size is same with valid data size.
69B93F00 A6DE021C 31303634 32373733 37396C61 73745F75
The last line is like this, which means “ "mRealTime":false}] ”, seems like the end of a string set.
226D5265 616C5469 6D65223A 66616C73 657D5D00 0000
I am checking the value size key by key.
from mmkv.
By the way, why are you using MULTI_PROCESS_MODE
in a single process App?
from mmkv.
It's a multi process App, I mean maybe we used SINGLE_PROCESS_MODE in some MULTI_PROCESS_MODE cases,
By the way, the last value mentioned before is actually a Json String of List, is there any possible the calculate of Json size occurred error?
from mmkv.
Json is just a String, nothing special. Is there any chance that there're some big items stored in MMKV and deleted afterward?
from mmkv.
I am not very sure of that, need further check, what's the exact definition of "big"?
from mmkv.
Items with size of 10K+ is consider big.
from mmkv.
Do you mean remove big items would not trigger file resize?
I add some log in MiniPBCoder::decodeOneMap:
{
int i = 0;
int j = 0;
while (!m_inputData->isAtEnd()) {
const auto &key = m_inputData->readString();
if (key.length() > 0) {
i++;
auto value = m_inputData->readData();
if (value.length() > 0) {
j += value.length();
dic[key] = move(value);
} else {
dic.erase(key);
}
}
}
MMKVInfo("total %d keys, value size %d", i, j);
}
loading [] with 4176233 size in total, file size is 134217728
loading [] with crc 4170586551 sequence 4
total 3412 keys, value size 4081561
loaded [***] with 1111 values
from mmkv.
I think I have found the reason, the futureUsage is over estimated:
size_t futureUsage = newSize * std::max<size_t>(8, (m_dic.size() + 1) / 2);
My last value size is 130K, m_dic.size() is 1000+, then the file will resize to 130M, but most of it will never been used.
This means, if I store thousands of keys in a file, it will very easy to cause OOM.
from mmkv.
Oh I see...Let me think about that.
from mmkv.
Fixed with this commit.
from mmkv.
I think it's good enough for me, thank you. How far will this release?
By the way, I found there is no reduce file size operation except "clearAll", if I store a lot of key-values in one file and then delete most of them in some time, it seems will waste some disk space.
Should I avoid this kind of usage as far as possible?
from mmkv.
That's a good suggestion. A trim
operation should be supported.
And by the way, the next minor release is not on schedule yet. I'll let you know by commenting on this issue when that happens.
from mmkv.
Waiting for good news, thank you very much!
from mmkv.
Release with v1.0.13, check it out.
from mmkv.
Wonderful!
from mmkv.
It seems use average item size to calc future usage does not merge into android code.
from mmkv.
It seems use average item size to calc future usage does not merge into android code.
I can't believe these, looks like there's a mistake on my local git repo.
Will fix soon.
from mmkv.
Fixed with this commit. A new version will likely come out next week.
from mmkv.
Look forward to it, thank you.
from mmkv.
Released with v1.0.14.
from mmkv.
Related Issues (20)
- 鸿蒙Next纯血版本如何接入mmkv? HOT 19
- crash with MMKV.getInt[DEDUPED] HOT 10
- 升级MMKV CRC校验失败 数据清理 HOT 1
- How to use it directly in C++? HOT 2
- Cheers! How to start to add #import <MMKV/MMKV.h> to my source file? HOT 2
- flutter use mmkv:1.3.0 , android application destory HOT 3
- crashed in Harmony Next Emulator API 11 x86_64 HOT 15
- minsdk 23 bump HOT 5
- The MMKV for HarmonyOS NEXT version lacks the interface for parsing the float type. HOT 17
- POSIX平台构建demo程序时报错 HOT 3
- MMKV for HarmonyOS NEXT 是否可以提供自定义对象的存取接口? HOT 4
- 多进程模式使用问题 HOT 1
- 在 HarmonyOS NEXT API 11 上初始化,发生崩溃,版本 : @tencent/mmkv":"1.3.5" HOT 1
- Fail to find any mmkv plugin dependencies HOT 3
- MMKV failed to build on iOS v1.3.5 HOT 4
- 一直有错误信息打印 HOT 1
- Query related to encryption key size increase HOT 1
- ohos中json字符串末尾分号丢失 HOT 4
- 鸿蒙 ide版本 Build Version: 5.0.3.100 api12 初始化的时候必现sysFreeze HOT 4
- MMKV crash (report from bugly) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mmkv.