From c8d2bc78902422c89607a5778857de958e3bb837 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 7 Feb 2016 03:40:41 +0500 Subject: 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 --- intern/cycles/device/device.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'intern/cycles/device/device.cpp') diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 02e9b0551c9..90211b23aa1 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -34,6 +34,8 @@ CCL_NAMESPACE_BEGIN bool Device::need_types_update = true; bool Device::need_devices_update = true; +vector Device::types; +vector Device::devices; /* Device Requested Features */ @@ -280,8 +282,6 @@ string Device::string_from_type(DeviceType type) vector& Device::available_types() { - static vector types; - if(need_types_update) { types.clear(); types.push_back(DEVICE_CPU); @@ -311,8 +311,6 @@ vector& Device::available_types() vector& Device::available_devices() { - static vector devices; - if(need_devices_update) { devices.clear(); #ifdef WITH_CUDA @@ -368,4 +366,10 @@ void Device::tag_update() need_devices_update = true; } +void Device::free_memory() +{ + types.free_memory(); + devices.free_memory(); +} + CCL_NAMESPACE_END -- cgit v1.2.3