[Bf-blender-cvs] [f68b2fd2331] master: RNA: Increase memory limit settings to their possible max on platform

Sergey Sharybin noreply at git.blender.org
Wed Jan 10 11:15:34 CET 2018


Commit: f68b2fd23312910fac1241d90f211b1bd41fc83c
Author: Sergey Sharybin
Date:   Thu Dec 21 11:07:59 2017 +0100
Branches: master
https://developer.blender.org/rBf68b2fd23312910fac1241d90f211b1bd41fc83c

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

===================================================================

M	source/blender/makesrna/intern/rna_userdef.c

===================================================================

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");



More information about the Bf-blender-cvs mailing list