[8735] New memory allocator for MaNGOS, based on Intel Threading Building Blocks library. Performance gains depend greatly on OS you use!

You should add two libraries into your server binaries:
tbb.so/tbbmalloc.so on *nix and tbb(_debug).dll/tbbmalloc(_debug).dll on Windows!!!

Define USE_STANDARD_MALLOC while compiling 'framework' project to use OS' default memory allocator!

Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
Ambal 2009-10-26 00:58:55 +02:00
parent 9e4b833054
commit a2ed351365
235 changed files with 52785 additions and 432 deletions

View file

@ -0,0 +1,69 @@
/*
* Copyright (C) 2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//lets use Intel scalable_allocator by default and
//switch to OS specific allocator only when _STANDARD_MALLOC is defined
#ifndef USE_STANDARD_MALLOC
#include "../../dep/tbb/include/tbb/scalable_allocator.h"
void * operator new(size_t sz) throw (std::bad_alloc)
{
void *res = scalable_malloc(sz);
if (NULL == res) throw std::bad_alloc();
return res;
}
void* operator new[](size_t sz) throw (std::bad_alloc)
{
void *res = scalable_malloc(sz);
if (NULL == res) throw std::bad_alloc();
return res;
}
void operator delete(void* ptr) throw()
{
scalable_free(ptr);
}
void operator delete[](void* ptr) throw()
{
scalable_free(ptr);
}
void* operator new(size_t sz, const std::nothrow_t&) throw()
{
return scalable_malloc(sz);
}
void* operator new[](size_t sz, const std::nothrow_t&) throw()
{
return scalable_malloc(sz);
}
void operator delete(void* ptr, const std::nothrow_t&) throw()
{
scalable_free(ptr);
}
void operator delete[](void* ptr, const std::nothrow_t&) throw()
{
scalable_free(ptr);
}
#endif