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>2015-02-14 21:26:07 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-02-15 00:01:48 +0300
commit18937f6fb5582f6a11bc3f732ae21d77b0219c39 (patch)
tree2396e80658467e23ccd8a1da1b3270a91f476f66 /intern/cycles/util
parentd0cc1180b0d28cd988d1c2f225524c15aa0addfa (diff)
Cycles: Add ifdef switch to use blender's guardedalloc for vector allocation
It's actually a bad level call, but it's inside ifdef block and disabled by default and only intended to be used for development purposes. Main idea of this change is to combine statistics coming from Cycles and Blender during scene synchronization step, to see if further changes are actually reducing memory footprint.
Diffstat (limited to 'intern/cycles/util')
-rw-r--r--intern/cycles/util/util_guarded_allocator.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/intern/cycles/util/util_guarded_allocator.h b/intern/cycles/util/util_guarded_allocator.h
index 4a7e0825388..263199417c4 100644
--- a/intern/cycles/util/util_guarded_allocator.h
+++ b/intern/cycles/util/util_guarded_allocator.h
@@ -17,10 +17,23 @@
#ifndef __UTIL_GUARDED_ALLOCATOR_H__
#define __UTIL_GUARDED_ALLOCATOR_H__
+/* Define this in order to use Blender's guarded allocator to keep
+ * track of allocated buffers, their sizes and peak memory usage.
+ *
+ * This is usually a bad level call, but it's really handy to keep
+ * track of overall peak memory consumption during the scene
+ * synchronization step.
+ */
+#undef WITH_BLENDER_GUARDEDALLOC
+
#include <memory>
#include "util_types.h"
+#ifdef WITH_BLENDER_GUARDEDALLOC
+# include "../../guardedalloc/MEM_guardedalloc.h"
+#endif
+
CCL_NAMESPACE_BEGIN
/* Internal use only. */
@@ -39,13 +52,21 @@ public:
T *allocate(size_t n, const void *hint = 0)
{
util_guarded_mem_alloc(n * sizeof(T));
+#ifdef WITH_BLENDER_GUARDEDALLOC
+ return (T*)MEM_mallocN(n * sizeof(T), "Cycles Alloc");
+#else
return std::allocator<T>::allocate(n, hint);
+#endif
}
void deallocate(T *p, size_t n)
{
util_guarded_mem_free(n * sizeof(T));
- return std::allocator<T>::deallocate(p, n);
+#ifdef WITH_BLENDER_GUARDEDALLOC
+ MEM_freeN((void*)p);
+#else
+ std::allocator<T>::deallocate(p, n);
+#endif
}
GuardedAllocator() : std::allocator<T>() { }