示例#1
0
/*********************************
 * global destructor - called at program
 * exit to clear out any allocated memory
 * and purge any global values.
 ********************************** */
void global_destroy( )
{
	double rate;
	/* add any global code here */
#ifdef MEX_MEMORY
	if (verbosity >= 1)
		printf("Clearing %d un-freed( ) memory blocks\n", malloc_hash->n);
		
	hash_destroy_array(malloc_hash);
	
	if (verbosity >= 1) {
		printf("------------ | memory cleaner statistics | -----------------\n");
		printf("Blocks allocated: %d\n", malloc_hash->numallocs);
		printf("Blocks freed: %d\n", malloc_hash->numfrees);
		printf("Block double-frees prevented: %d\n", malloc_hash->numdoubles);
		printf("Hash bucket collisions: %d\n", malloc_hash->collisions);
		printf("List traversal steps: %d\n", malloc_hash->numliststeps);
		
		rate = ((double)malloc_hash->collisions) / ((double)malloc_hash->numallocs);
		printf("Collision Rate: %0.3f\%\n", rate * 100);
		
		rate = 	(double) malloc_hash->numliststeps / 
				(double)(malloc_hash->numallocs + malloc_hash->numfrees) ;
		printf("Average list depth: %0.3f\n", rate);
	}
示例#2
0
/*********************************
 * global destructor - called at program
 * exit to clear out any allocated memory
 * and purge any global values.
 ********************************** */
void global_destroy( )
{
  hash_destroy_array(malloc_array);
  FREE(malloc_array);
}