Skip to content

Commit

Permalink
Add comments for Workspace2D destructor & test tearDowns
Browse files Browse the repository at this point in the history
Refs #8216
  • Loading branch information
martyngigg committed Mar 17, 2014
1 parent f564331 commit 015ca43
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Code/Mantid/Framework/DataObjects/src/Workspace2D.cpp
Expand Up @@ -28,6 +28,16 @@ namespace Mantid
Workspace2D::~Workspace2D()
{
// Clear out the memory

// The omp loop is here primarily for MSVC. On MSVC 2012
// when you allocate memory in a multithreaded loop, like our cow_ptrs will do,
// the deallocation time increases by a huge amount if the memory is just
// naively deallocated in a serial order. This is because when it was allocated
// in the omp loop then the actual memory ends up being interleaved and
// then trying to deallocate this serially leads to lots of swapping in and out of
// memory.
// See http://social.msdn.microsoft.com/Forums/en-US/2fe4cfc7-ca5c-4665-8026-42e0ba634214/visual-studio-2012-slow-deallocation-when-new-called-within-openmp-loop?forum=vcgeneral

PARALLEL_FOR1(this)
for (int64_t i=0; i < static_cast<int64_t>(data.size()); i++)
{
Expand Down
5 changes: 5 additions & 0 deletions Code/Mantid/Framework/TestHelpers/src/TearDownWorld.cpp
Expand Up @@ -5,6 +5,11 @@
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/AnalysisDataService.h"

// On MSVC all workspaces must be deleted by the time main() exits as the
// Workspace destruction can call to an OpenMP loop which is not allowed
// on MSVC after main() exits.
// See Workspace2D::~Workspace2D()

namespace
{
/// Define single ClearAlgorithmManager object
Expand Down

0 comments on commit 015ca43

Please sign in to comment.