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-09-04 10:38:10 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-10-11 17:41:59 +0300
commit34e7285b0a62e0a4daa74caecbaea2932b13c05b (patch)
treeff7db3d1aee1bf56296af63c74d06d2a5c16d8f9 /intern/cycles/device/device_memory.h
parent27be9a2f3bdfc280a612b0d8137e473b2139ea76 (diff)
Cycles: Gracefully handle out-of-memory happening in device vector
Currently only image loading benefits of this and will give magenta color when image manager detects it's running out of memory. This isn't ideal solution and can't handle all cases. For example, OOM killer might kill process before it realized it run out of memory, but in other cases this could prevent some crashes. Reviewers: juicyfruit, dingto Differential Revision: https://developer.blender.org/D1502
Diffstat (limited to 'intern/cycles/device/device_memory.h')
-rw-r--r--intern/cycles/device/device_memory.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/intern/cycles/device/device_memory.h b/intern/cycles/device/device_memory.h
index ba79f8c88ae..8c32d03135e 100644
--- a/intern/cycles/device/device_memory.h
+++ b/intern/cycles/device/device_memory.h
@@ -211,7 +211,10 @@ public:
T *resize(size_t width, size_t height = 0, size_t depth = 0)
{
data_size = width * ((height == 0)? 1: height) * ((depth == 0)? 1: depth);
- data.resize(data_size);
+ if(data.resize(data_size) == NULL) {
+ clear();
+ return NULL;
+ }
data_width = width;
data_height = height;
data_depth = depth;
@@ -226,7 +229,9 @@ public:
T *copy(T *ptr, size_t width, size_t height = 0, size_t depth = 0)
{
T *mem = resize(width, height, depth);
- memcpy(mem, ptr, memory_size());
+ if(mem != NULL) {
+ memcpy(mem, ptr, memory_size());
+ }
return mem;
}