replaces another so it can do updates (e.g. dopesheet editor can sync channel selection). Also coded a simple optimization for allocating small objects, based on mempools. It's #ifdef'd out, you can enabled it by defining OPTIMIZE_SMALL_BLOCKS (e.g. adding -DDOPTIMIZE_SMALL_BLOCKS to your compiler flags). We suffer from a great deal of performance loss from the system allocator (vgroups, ghash, edgehash, the singly-linked list implementation in blenlib, editmesh, and likely a great many areas I'm forgetting), and this is the common solution for handling the many-small-objects problem. It's not really production-ready yet (it's long-term memory consequencers need to be profiled first, and the implementation tweaked as necassary), but for people on systems with slow system allocators it's worth trying. Note that since this creates a guardedalloc<->blenlib link, the build systems need to be updated accordingly (I've already done this for scons, though I'm not sure if the player builds).
45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
/**
|
|
* Simple fast memory allocator
|
|
*
|
|
*
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
*
|
|
* 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.
|
|
*
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
* All rights reserved.
|
|
*
|
|
* The Original Code is: all of this file.
|
|
*
|
|
* Contributor(s): Geoffrey Bantle.
|
|
*
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
*/
|
|
|
|
#ifndef BLI_MEMPOOL_H
|
|
#define BLI_MEMPOOL_H
|
|
|
|
struct BLI_mempool;
|
|
typedef struct BLI_mempool BLI_mempool;
|
|
|
|
BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, int use_sysmalloc);
|
|
void *BLI_mempool_alloc(BLI_mempool *pool);
|
|
void *BLI_mempool_calloc(BLI_mempool *pool);
|
|
void BLI_mempool_free(BLI_mempool *pool, void *addr);
|
|
void BLI_mempool_destroy(BLI_mempool *pool);
|
|
|
|
|
|
#endif
|