add --vips-leak

add --vips-leak flag for exit
This commit is contained in:
John Cupitt 2011-09-24 10:27:21 +01:00
parent 13e354e869
commit 0f46696f16
3 changed files with 14 additions and 11 deletions

View File

@ -17,6 +17,7 @@
- remove dmalloc support, was never used and valgrind is better - remove dmalloc support, was never used and valgrind is better
- im_csv2vips() allows quoted strings, including escaped quotes - im_csv2vips() allows quoted strings, including escaped quotes
- added vips_shutdown() - added vips_shutdown()
- added --vips-leak flag
10/8/11 started 7.26.3 10/8/11 started 7.26.3
- don't use G_VALUE_COLLECT_INIT(), many platforms do not have a glib this - don't use G_VALUE_COLLECT_INIT(), many platforms do not have a glib this

3
TODO
View File

@ -8,9 +8,6 @@
- add vips_init_argv() which processes argc/argv for you? handy for tiny - add vips_init_argv() which processes argc/argv for you? handy for tiny
progs, perhaps progs, perhaps
- add vips_shutdown()? unload plugins, drop cache etc. could test for leaks
too

View File

@ -89,6 +89,10 @@ GMutex *vips__global_lock = NULL;
*/ */
static char *vips__argv0 = NULL; static char *vips__argv0 = NULL;
/* Leak check on exit.
*/
static int vips__leak = 0;
/** /**
* vips_get_argv0: * vips_get_argv0:
* *
@ -279,20 +283,18 @@ vips_check_init( void )
/** /**
* vips_shutdown: * vips_shutdown:
* *
* Call this to drop caches and close plugins. Handy if you're doing leak * Call this to drop caches and close plugins. Run with "--vips-leak" to do
* checks. * a leak check too.
*/ */
void void
vips_shutdown( void ) vips_shutdown( void )
{ {
im_close_plugins();
vips_cache_drop_all(); vips_cache_drop_all();
#ifdef DEBUG_LEAK if( vips__leak )
printf( "** leak test on exit:\n" ); vips_object_print_all();
im__print_all();
printf( "** leak test done\n" ); im_close_plugins();
#endif /*DEBUG_LEAK*/
} }
const char * const char *
@ -330,6 +332,9 @@ static GOptionEntry option_entries[] = {
{ "vips-progress", 'p', 0, { "vips-progress", 'p', 0,
G_OPTION_ARG_NONE, &vips__progress, G_OPTION_ARG_NONE, &vips__progress,
N_( "show progress feedback" ), NULL }, N_( "show progress feedback" ), NULL },
{ "vips-leak", 'l', 0,
G_OPTION_ARG_NONE, &vips__leak,
N_( "leak-check on exit" ), NULL },
{ "vips-disc-threshold", 'd', 0, { "vips-disc-threshold", 'd', 0,
G_OPTION_ARG_STRING, &vips__disc_threshold, G_OPTION_ARG_STRING, &vips__disc_threshold,
N_( "images larger than N are decompressed to disc" ), "N" }, N_( "images larger than N are decompressed to disc" ), "N" },