Cycles: Always use guarded allocator of vectors
authorSergey Sharybin <sergey.vfx@gmail.com>
Sat, 6 Feb 2016 22:40:41 +0000 (03:40 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 12 Feb 2016 14:43:26 +0000 (15:43 +0100)
commitc8d2bc78902422c89607a5778857de958e3bb837
tree73355a2912eb64be5ecbe52f2d42b1da60d10f0c
parent28604c46a137c1288cc7a494b36ed72e44a0ab8b
Cycles: Always use guarded allocator of vectors

We don't have vectors re-allocation happening multiple times from inside
a loop anymore, so we can safely switch to a memory guarded allocator for
vectors and keep track on the memory usage at various stages of rendering.

Additionally, when building from inside Blender repository, Cycles will
use Blender's guarded allocator, so actual memory usage will be displayed
in the Space Info header.

There are couple of tricky aspects of the patch:

- TaskScheduler::exit() now explicitly frees memory used by `threads`.
  This is needed because `threads` is a static member which destructor
  isn't getting called on Blender's exit which caused memory leak print
  to happen.

  This shouldn't give any measurable speed issues, reallocation of that
  vector is only one of fewzillion other allocations happening during
  synchronization.

- Use regular guarded malloc (not aligned one). No idea why it was
  made to be aligned in the first place. Perhaps some corner case tests
  or so. Vector was never expected to be aligned anyway. Let's see if
  we'll have actual bugs with this.

Reviewers: dingto, lukasstockner97, juicyfruit, brecht

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D1774
14 files changed:
intern/cycles/CMakeLists.txt
intern/cycles/blender/addon/__init__.py
intern/cycles/blender/addon/engine.py
intern/cycles/blender/blender_python.cpp
intern/cycles/device/device.cpp
intern/cycles/device/device.h
intern/cycles/render/scene.cpp
intern/cycles/render/shader.cpp
intern/cycles/render/shader.h
intern/cycles/util/CMakeLists.txt
intern/cycles/util/util_guarded_allocator.h
intern/cycles/util/util_task.cpp
intern/cycles/util/util_task.h
intern/cycles/util/util_vector.h