summary refs log tree commit diff
path: root/src/Cache.cpp
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2022-07-20 14:04:06 +0200
committerGitHub <noreply@github.com>2022-07-20 14:04:06 +0200
commita5dafec147414d34b912a508422ec0831a643eda (patch)
treeab11a11408d710ea5dcfdb62c21e11fa4f4d54a7 /src/Cache.cpp
parentMerge pull request #1123 from LordMZTE/rofi-nheko (diff)
parentfixup! Better handle 32-bit platforms by limitting database size (diff)
downloadnheko-a5dafec147414d34b912a508422ec0831a643eda.tar.xz
Merge pull request #1121 from MayeulC/32bit
Better handle 32-bit platforms by limitting database size
Diffstat (limited to '')
-rw-r--r--src/Cache.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp

index 4213e901..c740cc55 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp
@@ -46,12 +46,19 @@ static const std::string_view OLM_ACCOUNT_KEY("olm_account"); static const std::string_view CACHE_FORMAT_VERSION_KEY("cache_format_version"); static const std::string_view CURRENT_ONLINE_BACKUP_VERSION("current_online_backup_version"); -constexpr size_t MAX_RESTORED_MESSAGES = 30'000; - -constexpr auto DB_SIZE = 32ULL * 1024ULL * 1024ULL * 1024ULL; // 32 GB constexpr auto MAX_DBS = 32384UL; constexpr auto BATCH_SIZE = 100; +#if Q_PROCESSOR_WORDSIZE >= 5 // 40-bit or more, up to 2^(8*WORDSIZE) words addressable. +constexpr auto DB_SIZE = 32ULL * 1024ULL * 1024ULL * 1024ULL; // 32 GB +constexpr size_t MAX_RESTORED_MESSAGES = 30'000; +#elif Q_PROCESSOR_WORDSIZE == 4 // 32-bit address space limits mmaps +constexpr auto DB_SIZE = 1ULL * 1024ULL * 1024ULL * 1024ULL; // 1 GB +constexpr size_t MAX_RESTORED_MESSAGES = 5'000; +#else +#error Not enough virtual address space for the database on target CPU +#endif + //! Cache databases and their format. //! //! Contains UI information for the joined rooms. (i.e name, topic, avatar url etc).