Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed Jul 12, 2024
1 parent 5e5a3fe commit 41dbe81
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ww/managers/memory_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ struct dedicated_memory_s
{
hhybridmutex_t mut;
wof_allocator_t *wof_state;
unsigned int free_counter;
};

static dedicated_memory_t *state;

enum
{
kFreeThreShouldCounter = 64
};

#ifdef ALLOCATOR_BYPASS

dedicated_memory_t *createWWMemoryManager()
Expand Down Expand Up @@ -61,9 +67,8 @@ void setWWMemoryManager(dedicated_memory_t *new_state)
dedicated_memory_t *createWWDedicatedMemory(void)
{
dedicated_memory_t *dm = malloc(sizeof(dedicated_memory_t));
*dm = (struct dedicated_memory_s) {.free_counter = 0, .wof_state = wof_allocator_new()};
hhybridmutex_init(&dm->mut);
dm->wof_state = wof_allocator_new();

return dm;
}

Expand Down Expand Up @@ -98,6 +103,11 @@ void wwmDedicatedFree(dedicated_memory_t *dm, void *ptr)
{
hhybridmutex_lock(&dm->mut);
wof_free(dm->wof_state, ptr);
if (state->free_counter++ > kFreeThreShouldCounter)
{
wof_gc(state->wof_state);
state->free_counter = 0;
}
hhybridmutex_unlock(&dm->mut);
}

Expand Down

0 comments on commit 41dbe81

Please sign in to comment.