0

When I create a form with FXForms, it is very fluid, memory is ok. The problem is that the more you scroll down and up, the more memory is increasing which make the scroll very slow, very bad. I read in a ticket and another ticket that the tableview of that FXForms don't use cells recycling.

How can I find the way to resolve that problem?

- (UITableViewCell *)cellForField:(FXFormField *)field
{
    //FIXME: memory leak recycle cells

    //don't recycle cells - it would make things complicated
    Class cellClass = field.cellClass ?: [self cellClassForField:field];
    NSString *nibName = NSStringFromClass(cellClass);
    if ([nibName rangeOfString:@"."].location != NSNotFound)
    {
        nibName = nibName.pathExtension; //Removes Swift namespace
    }
    if ([field.mandatory isKindOfClass:[NSString class]])
    {
        if ([field.mandatory isEqualToString:@"YES"])
        {
            NSString *string = [field.title stringByReplacingOccurrencesOfString:@" " withString:@""];
            BOOL isNotEmpty = ![string isEqualToString:@""];
            if (isNotEmpty)
            {
                if (![[string substringToIndex:1] isEqualToString:mandatoryCharacter])
                {
                    [field setValue: [NSString stringWithFormat:@"%@%@", mandatoryCharacter, field.title] forKey:@"title"];
                }
            }
        }
    }
    if ([[NSBundle mainBundle] pathForResource:nibName ofType:@"nib"])
    {
        //load cell from nib
        return [[[NSBundle mainBundle] loadNibNamed:nibName owner:nil options:nil] firstObject];
    }
    else
    {
        //hackity-hack-hack
        UITableViewCellStyle style = UITableViewCellStyleDefault;
        if ([field valueForKey:@"style"])
        {
            style = [[field valueForKey:@"style"] integerValue];
        }
        else if (FXFormCanGetValueForKey(field.form, field.key))
        {
            style = UITableViewCellStyleValue1;
        }

        //don't recycle cells - it would make things complicated
        return [[cellClass alloc] initWithStyle:style reuseIdentifier:NSStringFromClass(cellClass)];
    }
}

Thanks in advance.

ΩlostA
  • 2,501
  • 5
  • 27
  • 63

1 Answers1

0

Put your code in autoreleasepool and check

e.g:

-(UITableViewCell *)cellForField:(FXFormField *)field {@autoreleasepool {}}