Skip to content
Snippets Groups Projects
Commit 9a27d3df authored by Janik Zikovsky's avatar Janik Zikovsky
Browse files

Refs #2187: Define and flags added around TCMalloc-specific code should allow...

Refs #2187: Define and flags added around TCMalloc-specific code should allow it to compile whether or not you have TCMalloc.
parent 264bbb00
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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)
......
......@@ -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";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment