Changeset 6654 for trunk/ARBDB/gb_prot.h

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/gb_prot.h

    r6648 r6654  
    8888 
    8989/* admalloc.cxx */ 
     90void gbm_flush_mem(void); 
    9091void gbm_init_mem(void); 
    91 void gbm_debug_mem(GB_MAIN_TYPE *Main); 
     92void gbm_debug_mem(void); 
    9293 
    9394/* adoptimize.cxx */ 
     
    176177struct gb_compress_tree *gb_build_uncompress_tree(const unsigned char *data, long short_flag, char **end); 
    177178void gb_free_compress_tree(struct gb_compress_tree *tree); 
    178 struct gb_compress_list *gb_build_compress_list(const unsigned char *data, long short_flag, long *size); 
     179gb_compress_list *gb_build_compress_list(const unsigned char *data, long short_flag, long *size); 
    179180char *gb_compress_bits(const char *source, long size, const unsigned char *c_0, long *msize); 
    180181GB_BUFFER gb_uncompress_bits(const char *source, long size, char c_0, char c_1);