gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Solved: big memory leak in GSString


From: Pirmin Braun
Subject: Re: Solved: big memory leak in GSString
Date: Mon, 14 Jan 2013 13:43:37 +0100

after implementing a compare: method in PBIDMLine and replacing the 
sortUsingKeyOrderArray: by sortUsingSelector:@selector(compare:) it works; the 
memory consumption is back down to 57 MB. Thanks to all who helped!

btw. the sortUsingKeyOrderArray: wasn't from GNUStep, I guess it came from GDL; 
it looked like that:

- (void) sortUsingKeyOrderArray: (NSArray *)orderArray
{
  if ([self count] > 1)
    {
      [self sortUsingFunction:compareUsingSortOrderings  context:orderArray];
    }
}

static NSComparisonResult
compareUsingSortOrderings(id    left,
                          id    right,
                          void* vpSortOrders)
{
    NSArray           *sortOrders = (NSArray *)vpSortOrders;
    NSComparisonResult r = NSOrderedSame;
    unsigned int       i;
    unsigned int       sortOrdCnt = [sortOrders count];

    /* Loop over all sort orderings until we have an ordering difference. */
    for (i=0; (r == NSOrderedSame) && (i < sortOrdCnt); i++){
        PBSortOrdering *sortOrd  = [sortOrders objectAtIndex: i];
        NSString       *key      = [sortOrd key];
        SEL             compSel  = [sortOrd selector];
        id              leftVal  = [left  valueForKeyPath: key];
        id              rightVal = [right valueForKeyPath: key];
        NSComparisonResult (*imp)(id, SEL, id);

        if(!leftVal && !rightVal)continue;
        if(!leftVal)return NSOrderedAscending;
        if(!rightVal)return NSOrderedDescending;

        imp = (NSComparisonResult (*)(id, SEL, id))[leftVal methodForSelector: 
compSel];
        NSCAssert3(imp!=NULL,
                   @"Invalid comparison selector:%@ for object:<%@ 0x%x>",
                   NSStringFromSelector(compSel),
                   NSStringFromClass([leftVal class]),
                   leftVal);
        r = (*imp)(leftVal, compSel, rightVal);

    }

    return r;
}


-- 
Pirmin Braun - IntarS Unternehmenssoftware GmbH - Sinziger Str. 29a - 53424 
Remagen
+49 2642 308288 +49 174 9747584 - skype:pirminb www.intars.de  address@hidden 
intars.sourceforge.net
Geschäftsführer: Pirmin Braun, Ralf Engelhardt Registergericht: Amtsgericht 
Coburg HRB3136



reply via email to

[Prev in Thread] Current Thread [Next in Thread]