forked from enlightenment/efl
eina: change default policy of Chained Mempool to recycle memory right away.
Until now, Chained Mempool would first empty its pool and the started to recycle memory. Now it does always try to recycle first. This should limit memory fragmentation to some extend. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D10534
This commit is contained in:
parent
d1e603f688
commit
d8edcbaeb8
|
@ -182,16 +182,10 @@ _eina_chained_mempool_usage_cmp(const Eina_Inlist *l1, const Eina_Inlist *l2)
|
|||
static void *
|
||||
_eina_chained_mempool_alloc_in(Chained_Mempool *pool, Chained_Pool *p)
|
||||
{
|
||||
void *mem;
|
||||
void *mem = NULL;
|
||||
|
||||
if (p->last)
|
||||
{
|
||||
mem = p->last;
|
||||
p->last += pool->item_alloc;
|
||||
if (p->last >= p->limit)
|
||||
p->last = NULL;
|
||||
}
|
||||
else
|
||||
// Let's try to first recycle memory
|
||||
if (p->base)
|
||||
{
|
||||
#ifndef NVALGRIND
|
||||
VALGRIND_MAKE_MEM_DEFINED(p->base, pool->item_alloc);
|
||||
|
@ -199,6 +193,13 @@ _eina_chained_mempool_alloc_in(Chained_Mempool *pool, Chained_Pool *p)
|
|||
// Request a free pointer
|
||||
mem = eina_trash_pop(&p->base);
|
||||
}
|
||||
else if (p->last)
|
||||
{
|
||||
mem = p->last;
|
||||
p->last += pool->item_alloc;
|
||||
if (p->last >= p->limit)
|
||||
p->last = NULL;
|
||||
}
|
||||
|
||||
// move to end - it just filled up
|
||||
if (!p->base && !p->last)
|
||||
|
@ -306,7 +307,7 @@ eina_chained_mempool_malloc(void *data, EINA_UNUSED unsigned int size)
|
|||
|
||||
// we have reached the end of the list - no free pools
|
||||
if (!p)
|
||||
{
|
||||
{
|
||||
//new chain created ,point it to be the first_fill chain
|
||||
pool->first_fill = _eina_chained_mp_pool_new(pool);
|
||||
if (!pool->first_fill)
|
||||
|
|
Loading…
Reference in New Issue