summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/storage_lmdb.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/common/storage_lmdb.cpp b/common/storage_lmdb.cpp
index ddad69d..b60f707 100644
--- a/common/storage_lmdb.cpp
+++ b/common/storage_lmdb.cpp
@@ -915,6 +915,21 @@ DataStore::Transaction::Stat DataStore::Transaction::stat(bool printDetails)
915 return {mei.me_last_pgno + 1, freePages, mst.ms_psize, mainStat, freeStat}; 915 return {mei.me_last_pgno + 1, freePages, mst.ms_psize, mainStat, freeStat};
916} 916}
917 917
918static size_t mapsize()
919{
920 if (RUNNING_ON_VALGRIND) {
921 // In order to run valgrind this size must be smaller than half your available RAM
922 // https://github.com/BVLC/caffe/issues/2404
923 return (size_t)1048576 * (size_t)1000; // 1MB * 1000
924 }
925#ifdef Q_OS_WIN
926 //Windows home 10 has a virtual address space limit of 128GB(https://msdn.microsoft.com/en-us/library/windows/desktop/aa366778(v=vs.85).aspx#physical_memory_limits_windows_10)
927 return (size_t)1048576 * (size_t)100000; // 1MB * 100'000
928#else
929 //This is the maximum size of the db (but will not be used directly), so we make it large enough that we hopefully never run into the limit.
930 return (size_t)1048576 * (size_t)100000; // 1MB * 100'000
931#endif
932}
918 933
919class DataStore::Private 934class DataStore::Private
920{ 935{
@@ -946,18 +961,8 @@ public:
946 } else { 961 } else {
947 //Limit large enough to accomodate all our named dbs. This only starts to matter if the number gets large, otherwise it's just a bunch of extra entries in the main table. 962 //Limit large enough to accomodate all our named dbs. This only starts to matter if the number gets large, otherwise it's just a bunch of extra entries in the main table.
948 mdb_env_set_maxdbs(env, 50); 963 mdb_env_set_maxdbs(env, 50);
949 if (RUNNING_ON_VALGRIND) { 964 if (const int rc = mdb_env_set_mapsize(env, mapsize())) {
950 // In order to run valgrind this size must be smaller than half your available RAM 965 SinkWarningCtx(logCtx) << "mdb_env_set_mapsize: " << rc << ":" << mdb_strerror(rc);
951 // https://github.com/BVLC/caffe/issues/2404
952 mdb_env_set_mapsize(env, (size_t)1048576 * (size_t)1000); // 1MB * 1000
953 } else {
954 //This is the maximum size of the db (but will not be used directly), so we make it large enough that we hopefully never run into the limit.
955#ifdef Q_OS_WIN
956 //Windows home 10 has a virtual address space limit of 128GB(https://msdn.microsoft.com/en-us/library/windows/desktop/aa366778(v=vs.85).aspx#physical_memory_limits_windows_10)
957 mdb_env_set_mapsize(env, (size_t)1048576 * (size_t)100000); // 1MB * 100'000
958#else
959 mdb_env_set_mapsize(env, (size_t)1048576 * (size_t)100000); // 1MB * 100'000
960#endif
961 } 966 }
962 const bool readOnly = (mode == ReadOnly); 967 const bool readOnly = (mode == ReadOnly);
963 unsigned int flags = MDB_NOTLS; 968 unsigned int flags = MDB_NOTLS;