use atexit() to call vips_shutdown()

This commit is contained in:
John Cupitt 2011-11-10 14:10:24 +00:00
parent 8fe50220d5
commit 786eca0d3e
4 changed files with 35 additions and 73 deletions

View File

@ -42,6 +42,7 @@
- added ARRAY interpretation for images
- VipsStats tracks minpos/maxpos as well
- moved mask/ to deprecated
- use atexit() to call vips_shutdown()
12/10/11 started 7.26.6
- NOCACHE was not being set correctly on OS X causing performance

57
TODO
View File

@ -2,67 +2,10 @@
- im_open_local() is broken? try Adam's prog under 7.27
... it's the operation cache, we just need to call vips_shutdown()
- see: vips_abs_build(), should that set an arithmetic member? ugly
- what about pipeline -> bandsplit -> min
will that eval the pipe once for each band, or will caching stop that?
nope, once for each band argh
get im_stats() to report minpos and maxpos
- try:
$ vips vips copy babe.png x.v
GLib-GObject-WARNING **: invalid cast from `VipsFormatVips' to
`VipsOperation'
if( !(type = vips_type_find( "VipsOperation", "vips" )) )
return( NULL );
is finding VipsFormatVips
though VipsFormatVips is not a subclass of VipsOperation ?!?!?
vips_type_find() was always searching the whole of VipsObject and ignoring
basename
changed it back, but what will this break? there was a reason we got rid of
subclass searching I forget what
- don't do vips_image_write() at the end of a pipeline, instead try:
g_object_set( object, "out", t, NULL );
ie. replace the output object
this doesn't work, I wonder why ... do we need to add an extra ref to t?
yes, the old obj holds a ref to the operation, not the other way around
- vipsimage should be cached too, eg.
VipsImage *a = vips_image_new_from_file( "poop.jpg" );

View File

@ -266,7 +266,7 @@ AC_TYPE_SIZE_T
AC_FUNC_MEMCMP
AC_FUNC_MMAP
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([getcwd gettimeofday getwd memset munmap putenv realpath strcasecmp strchr strcspn strdup strerror strrchr strspn vsnprintf realpath mkstemp mktemp random rand sysconf])
AC_CHECK_FUNCS([getcwd gettimeofday getwd memset munmap putenv realpath strcasecmp strchr strcspn strdup strerror strrchr strspn vsnprintf realpath mkstemp mktemp random rand sysconf atexit])
AC_CHECK_LIB(m,cbrt,[AC_DEFINE(HAVE_CBRT,1,[have cbrt() in libm.])])
AC_CHECK_LIB(m,hypot,[AC_DEFINE(HAVE_HYPOT,1,[have hypot() in libm.])])

View File

@ -262,6 +262,13 @@ vips_init( const char *argv0 )
*/
vips_vector_init();
/* Register vips_shutdown(). This may well not get called and many
* platforms don't support it anyway.
*/
#ifdef HAVE_ATEXIT
atexit( vips_shutdown );
#endif /*HAVE_ATEXIT*/
done = TRUE;
return( 0 );
@ -280,38 +287,49 @@ vips_check_init( void )
vips_error_clear();
}
static void
vips_leak( void )
{
char txt[1024];
VipsBuf buf = VIPS_BUF_STATIC( txt );
vips_object_print_all();
vips_buf_appendf( &buf, "memory: %d allocations, %zd bytes\n",
vips_tracked_get_allocs(), vips_tracked_get_mem() );
vips_buf_appendf( &buf, "memory: high-water mark " );
vips_buf_append_size( &buf, vips_tracked_get_mem_highwater() );
vips_buf_appendf( &buf, "\nfiles: %d open\n",
vips_tracked_get_files() );
fprintf( stderr, "%s", vips_buf_all( &buf ) );
}
/**
* vips_shutdown:
*
* Call this to drop caches and close plugins. Run with "--vips-leak" to do
* a leak check too.
* a leak check too. May be called many times.
*/
void
vips_shutdown( void )
{
static gboolean done = FALSE;
vips_cache_drop_all();
im_close_plugins();
/* In dev releases, always show leaks.
/* In dev releases, always show leaks. But not more than once, it's
* annoying.
*/
#ifndef DEBUG_LEAK
if( vips__leak )
#endif /*DEBUG_LEAK*/
{
char txt[1024];
VipsBuf buf = VIPS_BUF_STATIC( txt );
if( !done )
vips_leak();
vips_object_print_all();
vips_buf_appendf( &buf, "memory: %d allocations, %zd bytes\n",
vips_tracked_get_allocs(),
vips_tracked_get_mem() );
vips_buf_appendf( &buf, "memory: high-water mark " );
vips_buf_append_size( &buf, vips_tracked_get_mem_highwater() );
vips_buf_appendf( &buf, "\nfiles: %d open\n",
vips_tracked_get_files() );
fprintf( stderr, "%s", vips_buf_all( &buf ) );
done = TRUE;
}
}