Beispiel #1
0
void
qxl_mem_dump_stats   (struct qxl_mem         *mem,
		      const char             *header)
{
    ErrorF ("%s\n", header);
    
    mspace_malloc_stats (mem->space);
}
Beispiel #2
0
void
public_mSTATs(void)
{
  int i;
  struct malloc_arena* ar_ptr;
  /*unsigned long in_use_b, system_b, avail_b;*/
#if THREAD_STATS
  long stat_lock_direct = 0, stat_lock_loop = 0, stat_lock_wait = 0;
#endif

  if(__malloc_initialized < 0)
    ptmalloc_init ();
  for (i=0, ar_ptr = &main_arena;; ++i) {
    struct malloc_state* msp = arena_to_mspace(ar_ptr);

    fprintf(stderr, "Arena %d:\n", i);
    mspace_malloc_stats(msp);
#if THREAD_STATS
    stat_lock_direct += ar_ptr->stat_lock_direct;
    stat_lock_loop += ar_ptr->stat_lock_loop;
    stat_lock_wait += ar_ptr->stat_lock_wait;
#endif
    if (MALLOC_DEBUG > 1) {
      struct malloc_segment* mseg = &msp->seg;
      while (mseg) {
	fprintf(stderr, " seg %08lx-%08lx\n", (unsigned long)mseg->base,
		(unsigned long)(mseg->base + mseg->size));
	mseg = mseg->next;
      }
    }
    ar_ptr = ar_ptr->next;
    if (ar_ptr == &main_arena)
      break;
  }
#if THREAD_STATS
  fprintf(stderr, "locked directly  = %10ld\n", stat_lock_direct);
  fprintf(stderr, "locked in loop   = %10ld\n", stat_lock_loop);
  fprintf(stderr, "locked waiting   = %10ld\n", stat_lock_wait);
  fprintf(stderr, "locked total     = %10ld\n",
          stat_lock_direct + stat_lock_loop + stat_lock_wait);
  if (main_arena.stat_starter > 0)
    fprintf(stderr, "starter hooks    = %10ld\n", main_arena.stat_starter);
#endif
}
Beispiel #3
0
int main(int argc, char *argv[])
{
	size_t size1 = 255;
	void *addr1 = NULL;
	size_t size2 = 256;
	void *addr2 = NULL;
	size_t size3 = kMaxCodeCacheCapacity - 512;
	void *addr3 = NULL;
		
	gExecutableStore = malloc(kMaxCodeCacheCapacity);
	if (gExecutableStore == NULL) {
		printf("error malloc\n");
		return -1;
	}
    gMspace = create_mspace_with_base(gExecutableStore, kMaxCodeCacheCapacity,
              /*locked=*/ true);
    
    printf("-> create mspace\n");
    mspace_malloc_stats(gMspace);
              
	addr1 = mspace_malloc(gMspace, size1);
	if (addr1 != NULL) {
		printf("-> malloc addr1 = %p, 0x%x\n", addr1, (uint32_t)size1);
		mspace_malloc_stats(gMspace);
		printf("addr1 size = 0x%x\n", (uint32_t)mspace_usable_size(addr1));
	}					
	
	addr2 = mspace_malloc(gMspace, size2);
	if (addr2 != NULL) {
		printf("-> malloc addr2 = %p, 0x%x\n", addr2, (uint32_t)size2);
		mspace_malloc_stats(gMspace);
		printf("addr2 size = 0x%x\n", (uint32_t)mspace_usable_size(addr2));
	}	
				
	addr3 = mspace_malloc(gMspace, size3);
	if (addr3 != NULL) {
		printf("-> malloc addr3 = %p, 0x%x\n", addr3, (uint32_t)size3);
		mspace_malloc_stats(gMspace);
		printf("addr3 size = 0x%x\n", (uint32_t)mspace_usable_size(addr3));
	} else {
		printf("malloc addr3 error!\n");
	}			

	if (addr1 != NULL) {
		mspace_free(gMspace, addr1);
	}
	
	if (addr2 != NULL) {
		mspace_free(gMspace, addr2);
	}				

	if (addr3 != NULL) {
		mspace_free(gMspace, addr3);
	}				
	
	printf("-> all free\n");
	mspace_malloc_stats(gMspace);
              
_exit:
	if (gMspace != NULL) {
		destroy_mspace(gMspace);
		gMspace = NULL;
	}
	
	if (gExecutableStore != NULL) {
		free(gExecutableStore);
		gExecutableStore = NULL;
	}			
	
	return 0;
} 
Beispiel #4
0
void gm_stats() {
    assert(GM);
    mspace_malloc_stats(GM->mspace_ptr);
}