Hi folks,

I am sending a code fragment that you may find useful. It prints the
classes that have the most objects allocated. Paste into your program and
call with the number of classes you wish to see. Here is the code:



typedef struct {
    Class what;
    long count;
} debugclinf;

int cmpbycount(const void *a, const void *b)
{
    return ((debugclinf *)b)->count-((debugclinf *)a)->count;
}

void classlist(int top)
{
    Class *list = GSDebugAllocationClassList(), *ptr = list;
    int lsize = 0;
    while(*ptr!=NULL){
        lsize++;
        ptr++;
    }
    
    if(top>lsize){
        top=lsize;
    }

    debugclinf clist[lsize];
    int ind = 0; ptr = list;
    while(*ptr!=NULL){
        clist[ind].what = *ptr;
        clist[ind].count = GSDebugAllocationCount(*ptr);
        ind++;
        ptr++;
    }

    qsort(clist, lsize, sizeof(debugclinf), cmpbycount);

    for(ind=0; ind<top; ind++){
        GSPrintf(stdout, @"%12ld [EMAIL PROTECTED]", 
                 clist[ind].count, 
                 NSStringFromClass(clist[ind].what));
    }
}


This has helped me find memory leaks.

Best regards,

Marko



+-------------------------------------------------------------+
| Marko Riedel, EDV Neue Arbeit gGmbH, [EMAIL PROTECTED] |
| http://www.geocities.com/markoriedelde/index.html           |
+-------------------------------------------------------------+


        

        
                
___________________________________________________________ 
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de


_______________________________________________
Discuss-gnustep mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to