⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 settings.dist

📁 减少内存碎片的malloc分配函数
💻 DIST
📖 第 1 页 / 共 2 页
字号:
/* * Write the iteration count at the start of every log entry.  This is * handy when you are using the DMALLOC_START variable and want to * begin the tough debugging at a certain point.  This is also returned * by the dmalloc_mark() function. */#define LOG_ITERATION 1/* * Write the pid number at the start of every log entry if the * getpid() function is available.  This is handy when you are using * dmalloc with a program which forks.  See LOG_REOPEN below. */#define LOG_PID 0/* * If the getpid() function is available, notice when the pid of the * process changes and reopen the logfile.  This is handy when you are * using dmalloc with a program which forks and you want the separate * forked programs to have separate logs. * * NOTE: This only works if the %p string is in the logfile name * otherwise the log might reopen and clobber the existing log. */#define LOG_REOPEN 1/* * Store the number of times a pointer is "seen" being allocated or * freed -- it shows up as a s# (for seen) in the logfile.  This is * useful for tracking of not-freed memory.  See the documents for more * information. * * NOTE: This creates a certain amount of memory overhead. */#define LOG_PNT_SEEN_COUNT 1/* * Store the iteration count when a pointer is allocated -- it * shows up as a i# (for iteration) in the logfile.  This is to give * you some idea when during program execution, a pointer was * allocated but not freed. * * NOTE: This creates a certain amount of memory overhead. */#define LOG_PNT_ITERATION 0/* * At the front of each log message, print the output from the ctime() * function (not including the \n).  The TIME_NUMBER_TYPE is the type * that will store the output of time() and whose address we will pass * into ctime.  This requires that the ctime and time functions both * be defined. */#if LOG_TIME_NUMBER == 0#define LOG_CTIME_STRING	1#define TIME_TYPE		unsigned int#endif/* * Store the time (in seconds) or timeval (in seconds and * microseconds) when a pointer is allocated -- it shows up as a w# * (for when) in the logfile.  This is to give you some idea when a * pointer was allocated but not freed.  The library will log the * starting and the ending time if either of these flags is set. * TIMEVAL_INCLUDE is the include file to define struct timeval and * GET_TIMEVAL does the actual reading of the current time of day. * * WARNING: only TIME _or_ TIMEVAL can be defined at one time. * * NOTE: This creates a certain amount of memory overhead. */#define LOG_PNT_TIME		0#ifndef TIME_INCLUDE#define TIME_INCLUDE		<time.h>#endif#ifndef TIME_TYPE#define TIME_TYPE		unsigned int#endif#define LOG_PNT_TIMEVAL		0#define TIMEVAL_INCLUDE		<sys/time.h>#define TIMEVAL_TYPE		struct timeval#define GET_TIMEVAL(timeval)	(void)gettimeofday(&(timeval), NULL)/* * In OSF (anyone else?) you can setup __fini_* functions in each * module which will be called automagically at shutdown of the * program.  If you enable this variable, dmalloc will shut itself * down and log statistics when the program closes on its own.  Pretty * cool OS feature. */#define FINI_DMALLOC 0/* If you enable this, you probably want the AUTO_SHUTDOWN flag turned off */#if FINI_DMALLOC#undef AUTO_SHUTDOWN#define AUTO_SHUTDOWN 0#endif/* * Keep addresses that are freed from recycling back into the used * queue for a certain number of memory transactions.  For instance, * if this is set to 10 then after you free a pointer, it cannot be * reused until after 10 additional calls to malloc, free, realloc, * etc..  Define to 0 to disable.  NOTE: setting to 1 does nothing. * * For more drastic debugging, you can enable the never-reuse flag * which will cause the library to never reuse previously allocated * memory.  This may significantly expand the memory requirements of * your system however. */#define FREED_POINTER_DELAY 20/* * Size of the table of file and line number memory entries.  This * memory table records the top locations by file/line or * return-address of all pointers allocated.  It also tabulates the * freed memory pointers so you can easily locate the large memory * leaks.  See the MEMORY_TABLE_TOP_LOG value below to 0 to disable * the table. * * NOTE: The table will only hold the _first_ pointers into the table. * If you configure a size of 10 then the 11th pointer allocated will * not be accounted for. * * NOTE: the library will actually allocated 2 times this many entries * for speed reasons. */#define MEMORY_TABLE_SIZE 4096/* * This indicates how many of the top entries from the memory table * you want to log by default to the log file. * * NOTE: to display the top entries correctly, your OS must support * the quicksort function. */#define MEMORY_TABLE_TOP_LOG 10/* * Define this to 1 to only display the memory table summary of the * dumped table pointers.  The default is to display the summary as * well as the individual pointers so the individual leaks can be * tracked down. */#define DUMP_UNFREED_SUMMARY_ONLY 0/* * If (and _only_ if) your system does not have sbrk(), you can have * dmalloc pre-allocate its only heap space.  The default heap size is * 1mb but you can set the space to be any size.  For super-small * memory applications please understand that dmalloc is in no way * optimized for space and so you can easily run out of memory with * it. * * WARNING: this probably should only be used if HAVE_SBRK and * HAVE_MMAP are 0.  Please send me email with any problems or * comments on this feature. */#if HAVE_SBRK == 0 && HAVE_MMAP == 0#define INTERNAL_MEMORY_SPACE (1024 * 1024)#endif/* * The default smallest allowable allocations in bytes.  Any blocks asked  * for that are smaller will be rounded up to this size. */#define DEFAULT_SMALLEST_ALLOCATION	8/****************************** thread settings ******************************//* * The following definition allows use of the library in threaded * programs.  The most common package is MIT's pthreads so this is the * default.  Please send me mail if these definitions are configurable * enough to work with your thread package. */#ifndef LOCK_THREADS#define LOCK_THREADS 0#endif#if LOCK_THREADS/* * Which threads library header to include when needed.  It is assumed * that the types and functions in the THREAD_TYPE and THREAD_GET_ID * macros below are defined in this include file.  In addition, the * thread mutex init, lock, and unlock functions in malloc.c should * also be prototyped here. */#define THREAD_INCLUDE			<pthread.h>/* * As we approach the time when we start mutex locking the library, we * need to init the mutex variable.  This sets how many times before * we start locking should we init the variable taking in account that * the init itself might generate a call into the library.  Ugh. */#define THREAD_INIT_LOCK	2/* * For those threaded programs, the following settings allow the * library to log the identity of the thread that allocated a specific * pointer.  The thread-id will show up as a ``t'' followed by a * string identifying the thread.  The LOG_THREAD_ID macro says * whether the thread-id is logged at the front of all log messages. * The THREAD_TYPE macro defines the variable type of the id.  The * THREAD_GET_ID macro is what function to call to get the currently * running thread.  The THREAD_ID_TO_STRING defines how the thread-id * value is translated to the string necessary to be included with the * ``t'' in the logfile. */#define LOG_PNT_THREAD_ID		0#define THREAD_TYPE			pthread_t#define THREAD_GET_ID()			pthread_self()#if HAVE_SNPRINTF#define THREAD_ID_TO_STRING(buf, buf_size, thread_id)	\				(void)snprintf((buf), (buf_size), "%#lx", \					       (long)(thread_id))#else#define THREAD_ID_TO_STRING(buf, buf_size, thread_id)	\				(void)sprintf((buf), "%#lx", (long)(thread_id))#endif#endif /* LOCK_THREADS */#endif /* ! __SETTINGS_H__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -