Show
Ignore:
Timestamp:
13/05/10 17:30:03 (2 years ago)
Author:
westram
Message:
  • This patch stuffs all memory leaks in ARBDB (as far as covered by unit-tests) for DEBUG and NDEBUG version!
  • ARBDB global data (aka 'gb_local')
    • track number of opened/closed DBs
    • GBK_install_SIGSEGV_handler only once in GB_init_gb()
    • when closing last DB -> call GB_exit_gb() freeing more memory (also called atexit, including assertion failing if a DB is still open)
    • added class ARBDB_memory_manager (just calls gbm_init_mem + gbm_flush_mem)
    • GB_exit_gb flushes ARBDB_memory_manager (if all blocks were freed by gbm_free_mem, everything will be flushed)
  • fixed a few more static buffer leaks
  • gb_make_entry - alloc correct blocksizes for GB_STRING and GB_LINK
  • fixed a hack in gb_read_bin_rek_V2
    • was increasing size of memory block to avoid illegal memory access in decompress (introduced in [1003]; may occur again)
    • due to mismatch in size between gbm_get_mem and gbm_free_mem memory was never flushed even if all blocks have been freed
  • fixed memleak in gb_read_bin_rek_V2
    • when loading mapfile, previously created 'gb_main' was not freed
  • added allocation logger to admalloc.cxx (inactive - use TRACE_ALLOCS to activate it)
    • traces all allocs/frees of ARBDB managed memory
    • detects wrong usage (double free, size and index mismatch) and shows were the block was allocated
    • added new backtrace functions helpful for debugging (store stack-backtraces and print them later)
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ARBDB/adTest.cxx

    r6640 r6654  
    172172 
    173173    if (gb_father) { 
    174         char *father_path = strdup(GB_get_db_path(gb_father)); 
    175  
    176         static char *result; // careful! used recursively 
    177         freeset(result, GBS_global_string_copy("%s/%s", father_path, GB_KEY(gbd))); 
    178         free(father_path); 
    179  
    180         return result; 
     174        const char *father_path = GB_get_db_path(gb_father); 
     175 
     176        static SmartMallocPtr(char) result;        // careful! used recursively 
     177        char *key = GB_KEY(gbd); 
     178        result    = GBS_global_string_copy("%s/%s", father_path, key ? key : "<gbmain>"); 
     179 
     180        return &*result; 
    181181    } 
    182182    return "";