diff --git a/Code/Mantid/Framework/API/src/MemoryManager.cpp b/Code/Mantid/Framework/API/src/MemoryManager.cpp index 8b62729a25da5b99add876729636560104534893..3bff35cc798f4477ddfc2c775e1601294d400c1e 100644 --- a/Code/Mantid/Framework/API/src/MemoryManager.cpp +++ b/Code/Mantid/Framework/API/src/MemoryManager.cpp @@ -5,7 +5,9 @@ #include "MantidKernel/ConfigService.h" #include "MantidKernel/Memory.h" -//#include "/home/8oz/Code/google-perftools/src/google/malloc_extension.h" +#ifdef USE_TCMALLOC +#include "google/malloc_extension.h" +#endif // Get the 'meat' of this class from the appropriate file for the platform #ifdef __linux__ @@ -143,15 +145,17 @@ bool MemoryManagerImpl::goForManagedWorkspace(int NVectors, int XLength, int YLe void MemoryManagerImpl::releaseFreeMemory() { -// Kernel::MemoryStats mem; -// mem.update(); -// std::cout << "Before releasing: \n" << mem << "\n"; -// -// // Make TCMALLOC release memory to the system -// MallocExtension::instance()->ReleaseFreeMemory(); -// -// mem.update(); -// std::cout << "After releasing: \n" << mem << "\n"; +#ifdef USE_TCMALLOC + Kernel::MemoryStats mem; + mem.update(); + std::cout << "Before releasing: " << mem << "\n"; + + // Make TCMALLOC release memory to the system + MallocExtension::instance()->ReleaseFreeMemory(); + + mem.update(); + std::cout << "After releasing: " << mem << "\n"; +#endif } } // namespace API diff --git a/Code/Mantid/Framework/CMakeLists.txt b/Code/Mantid/Framework/CMakeLists.txt index c6f62086c85db59ce2824d907c329207ebaff999..b49be50d60716f36d7c20feea0c9e9b6a909f3d9 100644 --- a/Code/Mantid/Framework/CMakeLists.txt +++ b/Code/Mantid/Framework/CMakeLists.txt @@ -47,6 +47,8 @@ find_package ( Tcmalloc ) # If not found, or not wanted, just carry on without it if ( USE_TCMALLOC AND TCMALLOC_FOUND ) set ( TCMALLOC_LIBRARY ${TCMALLOC_LIBRARIES} ) + # Make a C++ define to use as flags in, e.g. MemoryManager.cpp + add_definitions ( -DUSE_TCMALLOC ) endif () # Might just as well link everything to Boost & Poco (found in CommonSetup) diff --git a/Code/Mantid/Framework/Kernel/src/Memory.cpp b/Code/Mantid/Framework/Kernel/src/Memory.cpp index 65156ec3a0b57b616528bec8cc2129b74e44b7c0..e528eb15f52209a3c4f7dd178df3de7b3c1220ed 100644 --- a/Code/Mantid/Framework/Kernel/src/Memory.cpp +++ b/Code/Mantid/Framework/Kernel/src/Memory.cpp @@ -30,7 +30,7 @@ string memToString(const TYPE mem_in_kiB) std::stringstream buffer; if (mem_in_kiB < static_cast<TYPE>(1024)) buffer << mem_in_kiB << "kiB"; - else if (mem_in_kiB < static_cast<TYPE>(1024 * 1024)) + else if (mem_in_kiB < static_cast<TYPE>(100 * 1024 * 1024)) buffer << (mem_in_kiB/static_cast<TYPE>(1024)) << "MiB"; else buffer << (mem_in_kiB/static_cast<TYPE>(1024*1024)) << "GiB";