"Markus Amsler" markus.amsler@oribi.org wrote:
void pool_destroy(struct pool* pool) {
- struct pool_arena* arena;
- struct pool_arena* next;
-#ifdef USE_STATS
- unsigned alloc, used, num;
- for (alloc = used = num = 0, arena = pool->first; arena; arena = arena->next)
- {
alloc += pool->arena_size;
used += arena->current - (char*)arena;
num++;
- }
- FIXME("STATS: pool %p has allocated %u kbytes, used %u kbytes in %u arenas,\n"
"\t\t\t\tnon-allocation ratio: %.2f%%\n",
pool, alloc >> 10, used >> 10, num, 100.0 - (float)used / (float)alloc * 100.0);
-#endif
- for (arena = pool->first; arena; arena = next)
- {
next = arena->next;
HeapFree(GetProcessHeap(), 0, arena);
- }
- pool_init(pool, 0);
- return;
}
The old code at least bothered to actually free some memory.
Dmitry Timoshkov wrote:
The old code at least bothered to actually free some memory.
Good point. I wasn't aware that some memory is only temporarily used. I'm going to rework it.
Markus
Markus Amsler a écrit :
Dmitry Timoshkov wrote:
The old code at least bothered to actually free some memory.
Good point. I wasn't aware that some memory is only temporarily used. I'm going to rework it.
Markus
does this patch gives you lots of improvements ? A+
Eric Pouech wrote:
Markus Amsler a écrit :
Dmitry Timoshkov wrote:
The old code at least bothered to actually free some memory.
Good point. I wasn't aware that some memory is only temporarily used. I'm going to rework it.
Markus
does this patch gives you lots of improvements ? A+
diff --git a/dlls/dbghelp/storage.c b/dlls/dbghelp/storage.c index e196143..c3ccaf5 100644 --- a/dlls/dbghelp/storage.c +++ b/dlls/dbghelp/storage.c @@ -73,30 +73,28 @@ void pool_destroy(struct pool* pool)
void* pool_alloc(struct pool* pool, unsigned len) {
struct pool_arena** parena; struct pool_arena* arena; void* ret;
len = (len + 3) & ~3; /* round up size on DWORD boundary */ assert(sizeof(struct pool_arena) + len <= pool->arena_size && len);
for (parena = &pool->first; *parena; parena = &(*parena)->next)
- for (arena = pool->first; arena; arena = arena->next) {
if ((char*)(*parena) + pool->arena_size - (*parena)->current >= len)
if ((char*)arena + pool->arena_size - arena->current >= len) {
ret = (*parena)->current;
(*parena)->current += len;
ret = arena->current;
}arena->current += len; return ret; }
- arena = HeapAlloc(GetProcessHeap(), 0, pool->arena_size); if (!arena) {FIXME("OOM\n");return NULL;}
- *parena = arena;
- ret = (char*)arena + sizeof(*arena);
- arena->next = NULL;
- arena->next = pool->first;
- pool->first = arena; arena->current = (char*)ret + len; return ret;
}
I cant try it at the moment, but I tried also the same approach. It went down from 100s to around 27s compared to 18s with Heap functions. The other problem here is, not all allocated memory is used, the gaps in not first nodes never gets filled. Also IMO memory allocation logic should only coded once. I will try it with the HeapCreate/HeapDestroy for every pool_init/pool_destroy as mentioned by Frank. Let's see what the overhead of HeapCreate is.
Markus
Markus Amsler a écrit :
I cant try it at the moment, but I tried also the same approach. It went down from 100s to around 27s compared to 18s with Heap functions. The other problem here is, not all allocated memory is used, the gaps in not first nodes never gets filled. Also IMO memory allocation logic should only coded once. I will try it with the HeapCreate/HeapDestroy for every pool_init/pool_destroy as mentioned by Frank. Let's see what the overhead of HeapCreate is.
you have to check the overhead both in terms of speed, but also in terms of overall memory consumption A+