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)
- 杀死APP,再打开保存的值会丢失,比如保存的1,打开变成0了 HOT 3
- OutOfMemoryError HOT 1
- Android 能不能发布一个 com.tencent:mmkv:mmkv:1.3.1 方便一下大家,mmkvdemo 使用的 kotlin 版本和项目冲突了,很难受 HOT 6
- Mmkv.clearAll() native crash. HOT 6
- Unable to find "libmmkv.so" library in system process when using MMKV in multi-process mode HOT 2
- Android MMKV代码中有一段疑惑 HOT 2
- 本地编译 Android 问题 HOT 1
- Android 遇到fail to mmap ,Out of memory HOT 3
- A SIGSEGV (SEGV_MAPERR) crash occurs when decode data HOT 1
- 初始化so 崩溃 HOT 3
- Bad JNI version returned from JNI_OnLoad HOT 3
- mmkv.decodeBytes() return null when encode an empty byte array HOT 3
- A native crash in colorOS-v1.3.2 HOT 11
- iOS17 系统 bugly卡顿上报有出现大量的 主线程死锁 HOT 5
- Why do I set the 'expireDurationInSecond' parameter but they don’t expire after the expiration time? HOT 2
- got crash on CodedInputData HOT 10
- [Help] Cross complie for aarch64(arm64) hosted on amd64 questions HOT 13
- Macro "release_key" defined in "MMKV.h" pullute the global scope. HOT 2
- Does MMKV implement custom encryption? HOT 2
- Android 接入1.3.2版本发生崩溃 HOT 4
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.