track local mem allocs for debugging
This commit is contained in:
parent
75b47962ef
commit
57b6622690
5
TODO
5
TODO
@ -5,11 +5,6 @@
|
||||
|
||||
- do conv and morph quickly as simple wrappers over the vips7 operations
|
||||
|
||||
- with VIPS_ARRAY() etc., we could note the mem use on the object we alloc
|
||||
local to, might make for interesting stats
|
||||
|
||||
does vips_malloc() used the tracked mem system?
|
||||
|
||||
- do much fancier profiling with timing on all locks saved in memory and
|
||||
dumped on exit
|
||||
|
||||
|
@ -456,6 +456,11 @@ struct _VipsObject {
|
||||
gboolean preclose;
|
||||
gboolean close;
|
||||
gboolean postclose;
|
||||
|
||||
/* Total memory allocated relative to this object, handy for
|
||||
* profiling.
|
||||
*/
|
||||
size_t local_memory;
|
||||
};
|
||||
|
||||
struct _VipsObjectClass {
|
||||
|
@ -150,9 +150,11 @@ vips_malloc( VipsObject *object, size_t size )
|
||||
|
||||
buf = g_malloc( size );
|
||||
|
||||
if( object )
|
||||
if( object ) {
|
||||
g_signal_connect( object, "postclose",
|
||||
G_CALLBACK( vips_malloc_cb ), buf );
|
||||
object->local_memory += size;
|
||||
}
|
||||
|
||||
return( buf );
|
||||
}
|
||||
@ -179,9 +181,11 @@ vips_strdup( VipsObject *object, const char *str )
|
||||
|
||||
str_dup = g_strdup( str );
|
||||
|
||||
if( object )
|
||||
if( object ) {
|
||||
g_signal_connect( object, "postclose",
|
||||
G_CALLBACK( vips_malloc_cb ), str_dup );
|
||||
object->local_memory += strlen( str );
|
||||
}
|
||||
|
||||
return( str_dup );
|
||||
}
|
||||
|
@ -1232,6 +1232,9 @@ vips_object_real_dump( VipsObject *object, VipsBuf *buf )
|
||||
{
|
||||
vips_buf_appendf( buf, " %s (%p)",
|
||||
G_OBJECT_TYPE_NAME( object ), object );
|
||||
|
||||
if( object->local_memory )
|
||||
vips_buf_appendf( buf, " %zd bytes", object->local_memory );
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2448,8 +2451,11 @@ vips_object_print_all_cb( VipsObject *object, int *n )
|
||||
char str[32768];
|
||||
VipsBuf buf = VIPS_BUF_STATIC( str );
|
||||
|
||||
fprintf( stderr, "%d) %s (%p)\n",
|
||||
fprintf( stderr, "%d) %s (%p)",
|
||||
*n, G_OBJECT_TYPE_NAME( object ), object );
|
||||
if( object->local_memory )
|
||||
fprintf( stderr, " %zd bytes", object->local_memory );
|
||||
fprintf( stderr, "\n" );
|
||||
|
||||
vips_object_summary_class( class, &buf );
|
||||
vips_buf_appends( &buf, " " );
|
||||
|
Loading…
Reference in New Issue
Block a user