Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-12-21 13:07:59 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-01-10 13:09:10 +0300
commitf68b2fd23312910fac1241d90f211b1bd41fc83c (patch)
treebdeb059867fc17bdf3e4711d5faaa6d0cb3a1f09 /source/blender/makesrna/intern/rna_userdef.c
parentf0610563ee5055a668be9a01f81bfe59b76355b0 (diff)
RNA: Increase memory limit settings to their possible max on platform
This is quite common to have 64GB memory now, and even 128. There is no reason to add any artificial caps on the cache and undo memory here. We can not protect against using too much memory in one cases and allow use of full computer potential in others. Now 32 bit will use 2GB max (as it used to be), but 64bit will use whatever number of megabytes fits into integer. Reviewers: campbellbarton, mont29 Subscribers: sebastian_k Differential Revision: https://developer.blender.org/D2972
Diffstat (limited to 'source/blender/makesrna/intern/rna_userdef.c')
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index f0313601c3a..71c53579585 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -24,6 +24,7 @@
* \ingroup RNA
*/
+#include <limits.h>
#include <stdlib.h>
#include "DNA_curve_types.h"
@@ -34,6 +35,7 @@
#include "DNA_scene_types.h"
#include "BLI_utildefines.h"
+#include "BLI_math_base.h"
#include "BKE_appdir.h"
#include "BKE_DerivedMesh.h"
@@ -670,6 +672,27 @@ static StructRNA *rna_AddonPref_refine(PointerRNA *ptr)
#else
+/* TODO(sergey): This technically belongs to blenlib, but we don't link
+ * makesrna against it.
+ */
+
+/* Get maximum addressable memory in megabytes, */
+static size_t max_memory_in_megabytes(void)
+{
+ /* Maximum addressable bytes on this platform. */
+ const size_t limit_bytes = (((size_t)1) << ((sizeof(size_t) * 8) - 1));
+ /* Convert it to megabytes and return. */
+ return (limit_bytes >> 20);
+}
+
+/* Same as above, but clipped to int capacity. */
+static int max_memory_in_megabytes_int(void)
+{
+ const size_t limit_megabytes = max_memory_in_megabytes();
+ /* NOTE: The result will fit into integer. */
+ return (int)min_zz(limit_megabytes, (size_t)INT_MAX);
+}
+
static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna)
{
StructRNA *srna;
@@ -3644,7 +3667,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
prop = RNA_def_property(srna, "undo_memory_limit", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "undomemory");
- RNA_def_property_range(prop, 0, 32767);
+ RNA_def_property_range(prop, 0, max_memory_in_megabytes_int());
RNA_def_property_ui_text(prop, "Undo Memory Size", "Maximum memory usage in megabytes (0 means unlimited)");
prop = RNA_def_property(srna, "use_global_undo", PROP_BOOLEAN, PROP_NONE);
@@ -4054,7 +4077,7 @@ static void rna_def_userdef_system(BlenderRNA *brna)
prop = RNA_def_property(srna, "memory_cache_limit", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "memcachelimit");
- RNA_def_property_range(prop, 0, (sizeof(void *) == 8) ? 1024 * 32 : 1024); /* 32 bit 2 GB, 64 bit 32 GB */
+ RNA_def_property_range(prop, 0, max_memory_in_megabytes_int());
RNA_def_property_ui_text(prop, "Memory Cache Limit", "Memory cache limit (in megabytes)");
RNA_def_property_update(prop, 0, "rna_Userdef_memcache_update");