add more logs to debug memory leak problem
This commit is contained in:
@@ -55,7 +55,7 @@ static pthread_mutex_t mtex = PTHREAD_MUTEX_INITIALIZER;
|
||||
//#define DEBUG_MEM_MNGT_ALLOC
|
||||
//-----------------------------------------------------------------------------
|
||||
#if defined(USER_MODE) && defined(DEBUG_MEM_MNGT_ALLOC)
|
||||
uint32_t counters[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
uint32_t counters[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
/*
|
||||
@@ -173,7 +173,7 @@ pool_buffer_clean (void *arg)
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
free_mem_block (mem_block_t * leP)
|
||||
free_mem_block (mem_block_t * leP, const char* caller)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -197,6 +197,11 @@ free_mem_block (mem_block_t * leP)
|
||||
list_add_tail_eurecom (leP, &mem_block_var.mem_lists[leP->pool_id]);
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC
|
||||
counters[leP->pool_id] -= 1;
|
||||
msg ("[%s][MEM_MNGT][INFO] after pool[%2d] freed: counters = {%2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d}\n",
|
||||
caller, leP->pool_id,
|
||||
counters[0],counters[1],counters[2],counters[3],counters[4],
|
||||
counters[5],counters[6],counters[7],counters[8],counters[9],
|
||||
counters[10],counters[11]);
|
||||
#endif
|
||||
leP = NULL; // this prevent from freeing the block twice
|
||||
} else {
|
||||
@@ -210,7 +215,7 @@ free_mem_block (mem_block_t * leP)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
mem_block_t *
|
||||
get_free_mem_block (uint32_t sizeP)
|
||||
get_free_mem_block (uint32_t sizeP, const char* caller)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
mem_block_t *le = NULL;
|
||||
@@ -242,11 +247,19 @@ get_free_mem_block (uint32_t sizeP)
|
||||
if ((le = list_remove_head (&mem_block_var.mem_lists[pool_selected]))) {
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC
|
||||
counters[pool_selected] += 1;
|
||||
msg ("[%s][MEM_MNGT][INFO] after pool[%2d] allocated: counters = {%2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d}\n",
|
||||
caller,
|
||||
pool_selected,
|
||||
counters[0],counters[1],counters[2],counters[3],counters[4],
|
||||
counters[5],counters[6],counters[7],counters[8],counters[9],
|
||||
counters[10],counters[11]);
|
||||
#endif
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC_SIZE
|
||||
msg ("[MEM_MNGT][INFO] ALLOC MEM_BLOCK SIZE %d bytes pool %d (%p)\n", sizeP, pool_selected,le);
|
||||
#endif
|
||||
|
||||
AssertFatal(le->pool_id == pool_selected, "Unexpected pool ID!");
|
||||
|
||||
#ifdef MEMBLOCK_BIG_LOCK
|
||||
if (pthread_mutex_unlock(&mtex)) abort();
|
||||
#endif
|
||||
@@ -263,6 +276,7 @@ get_free_mem_block (uint32_t sizeP)
|
||||
#endif
|
||||
} while (pool_selected++ < 12);
|
||||
|
||||
LOG_E(PHY, "[MEM_MNGT][ERROR][FATAL] failed allocating MEM_BLOCK size %d byes (pool_selected=%d size=%d)\n", sizeP, pool_selected, size);
|
||||
display_mem_load();
|
||||
mac_xface->macphy_exit("[MEM_MNGT][ERROR][FATAL] get_free_mem_block failed");
|
||||
|
||||
@@ -287,6 +301,13 @@ get_free_copy_mem_block (void)
|
||||
if ((le = list_remove_head (&mem_block_var.mem_lists[MEM_MNGT_POOL_ID_COPY]))) {
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC_SIZE
|
||||
msg ("[MEM_MNGT][INFO] ALLOC COPY MEM BLOCK (%p)\n",le);
|
||||
#endif
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC
|
||||
counters[MEM_MNGT_POOL_ID_COPY] += 1;
|
||||
msg ("[MEM_MNGT][INFO] pool counters = {%2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d %2d}\n",
|
||||
counters[0],counters[1],counters[2],counters[3],counters[4],
|
||||
counters[5],counters[6],counters[7],counters[8],counters[9],
|
||||
counters[10],counters[11]);
|
||||
#endif
|
||||
return le;
|
||||
} else {
|
||||
|
||||
@@ -55,8 +55,8 @@ typedef struct mem_block_t {
|
||||
|
||||
public_mem_block(void *pool_buffer_init (void);)
|
||||
public_mem_block(void *pool_buffer_clean (void *arg);)
|
||||
public_mem_block(void free_mem_block (mem_block_t * leP);)
|
||||
public_mem_block(mem_block_t* get_free_mem_block (uint32_t sizeP);)
|
||||
public_mem_block(void free_mem_block (mem_block_t * leP, const char* caller);)
|
||||
public_mem_block(mem_block_t* get_free_mem_block (uint32_t sizeP, const char* caller);)
|
||||
public_mem_block(mem_block_t *get_free_copy_mem_block (void);)
|
||||
public_mem_block(mem_block_t *get_free_copy_mem_block_up (void);)
|
||||
public_mem_block(mem_block_t *copy_mem_block (mem_block_t * leP, mem_block_t * destP);)
|
||||
|
||||
@@ -161,7 +161,7 @@ pool_buffer_clean (void *arg)
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
free_mem_block (mem_block_t * leP)
|
||||
free_mem_block (mem_block_t * leP, __func__)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -171,10 +171,10 @@ free_mem_block (mem_block_t * leP)
|
||||
}
|
||||
|
||||
#ifdef DEBUG_MEM_MNGT_FREE
|
||||
msg ("[MEM_MNGT][FREE] free_mem_block() %p pool: %d\n", leP, leP->pool_id);
|
||||
msg ("[MEM_MNGT][FREE] free_mem_block() %p pool: %d\n", leP, leP->pool_id, __func__);
|
||||
#endif
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC
|
||||
check_free_mem_block (leP);
|
||||
check_free_mem_block (leP, __func__);
|
||||
#endif
|
||||
|
||||
if (leP->pool_id <= MEM_MNGT_POOL_ID_COPY) {
|
||||
@@ -184,14 +184,14 @@ free_mem_block (mem_block_t * leP)
|
||||
#endif
|
||||
leP = NULL; // this prevent from freeing the block twice
|
||||
} else {
|
||||
msg ("[MEM_MNGT][FREE] ERROR free_mem_block() unknown pool_id : %d\n", leP->pool_id);
|
||||
msg ("[MEM_MNGT][FREE] ERROR free_mem_block() unknown pool_id : %d\n", leP->pool_id, __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
mem_block_t *
|
||||
get_free_mem_block (uint16_t sizeP)
|
||||
get_free_mem_block (uint16_t sizeP, __func__)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
mem_block_t *le = NULL;
|
||||
@@ -414,7 +414,7 @@ check_mem_area (void *arg)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
check_free_mem_block (mem_block_t * leP)
|
||||
check_free_mem_block (mem_block_t * leP, __func__)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
int block_index;
|
||||
|
||||
Reference in New Issue
Block a user