From 312204687e2eaa7dc6f2b6c27e79daab7426b5ff Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sat, 11 Apr 2009 16:08:54 +0000 Subject: [PATCH] stuff --- ChangeLog | 2 ++ include/vips/internal.h | 1 + libsrc/iofuncs/debug.c | 39 ++++++++++++++++++++++++++--------- libsrc/iofuncs/im_open_vips.c | 2 +- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 177fb629..bfe0a8e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ - tiny conv speedup - catch lcms error messages - fix includes for gtk+-3.0 +- report virtual memory too in im__print_all() 25/3/09 started 7.18.0 - revised version numbers @@ -356,6 +357,7 @@ - make im_stop_many(NULL) safe (Tom) 24/11/06 started 7.11.17 +1;5Q - better benchmark script makes graphing easier - double-buffer image file writes - reuse write threads diff --git a/include/vips/internal.h b/include/vips/internal.h index 89f344cf..2924a2c4 100644 --- a/include/vips/internal.h +++ b/include/vips/internal.h @@ -81,6 +81,7 @@ void im__write_2byte( unsigned char **to, unsigned char *from ); int im__ftruncate( int fd, gint64 pos ); int im__seek( int fd, gint64 pos ); int im__get_bytes( const char *filename, unsigned char buf[], int len ); +gint64 im__image_pixel_length( IMAGE *im ); int im__open_image_file( const char * ); void im__format_init( void ); diff --git a/libsrc/iofuncs/debug.c b/libsrc/iofuncs/debug.c index 5370ae2b..ed910844 100644 --- a/libsrc/iofuncs/debug.c +++ b/libsrc/iofuncs/debug.c @@ -41,6 +41,7 @@ #include #include +#include #ifdef WITH_DMALLOC #include @@ -51,7 +52,7 @@ GSList *im__open_images = NULL; static void * -print_one_line_region( REGION *r, int *n2, int *total ) +print_one_line_region( REGION *r, int *n2, gint64 *total ) { if( r->type == IM_REGION_BUFFER && r->buffer ) { printf( "\t*** %d) %zd malloced bytes\n", @@ -67,7 +68,7 @@ print_one_line_region( REGION *r, int *n2, int *total ) /* Print a one-line description of an image, with an index. */ static void * -print_one_line( IMAGE *im, int *n, int *total ) +print_one_line( IMAGE *im, int *n, gint64 *total ) { printf( "%2d) %p, %s, %s: %dx%d, %d bands, %s\n", *n, @@ -78,43 +79,61 @@ print_one_line( IMAGE *im, int *n, int *total ) *n += 1; if( im->dtype == IM_SETBUF && im->data ) { - int size = IM_IMAGE_SIZEOF_LINE( im ) * im->Ysize; + gint64 size = (gint64) IM_IMAGE_SIZEOF_LINE( im ) * im->Ysize; - printf( "\t*** %d malloced bytes\n", size ); + printf( "\t*** %lld malloced bytes\n", size ); *total += size; } if( im->regions ) { int n2; - int total2; + gint64 total2; printf( "\t%d regions\n", g_slist_length( im->regions ) ); + n2 = 0; total2 = 0; (void) im_slist_map2( im->regions, (VSListMap2Fn) print_one_line_region, &n2, &total2 ); if( total2 ) - printf( "\t*** using total of %d bytes\n", total2 ); + printf( "\t*** using total of %lld bytes\n", total2 ); *total += total2; } return( NULL ); } +static void * +add_virtual( IMAGE *im, gint64 *total, void *dummy ) +{ + *total += im__image_pixel_length( im ); + + return( NULL ); +} + /* Print one line for each open descriptor. */ void im__print_all( void ) { - int n = 0; - int total = 0; - if( im__open_images ) { + int n = 0; + gint64 total = 0; + + total = 0; printf( "%d images\n", g_slist_length( im__open_images ) ); (void) im_slist_map2( im__open_images, (VSListMap2Fn) print_one_line, &n, &total ); if( total ) - printf( "\n\t*** all-image total = %d bytes\n", total ); + printf( "\n\t*** all-image total = %lld real bytes\n", + total ); + + total = 0; + (void) im_slist_map2( im__open_images, + (VSListMap2Fn) add_virtual, &total, NULL ); + if( total ) + printf( "\n\t*** virtual total = %lld bytes\n", + total ); } } diff --git a/libsrc/iofuncs/im_open_vips.c b/libsrc/iofuncs/im_open_vips.c index 718096d3..78aa7f39 100644 --- a/libsrc/iofuncs/im_open_vips.c +++ b/libsrc/iofuncs/im_open_vips.c @@ -138,7 +138,7 @@ im__open_image_file( const char *filename ) * it's sometimes only 32 bits (eg. on many windows build environments) and we * want to always be 64 bit. */ -static gint64 +gint64 im__image_pixel_length( IMAGE *im ) { gint64 psize;