Skip to content

Saving memory #26

Description

@ericcheungidea

Problem:

I sync 15 MB files using FTASync and the instruments says that [FTASyncHandler syncAll] takes 15MB memory which is not reasonable

So I changed the code in FTASyncParent.m :

- (void)updateObjectWithRemoteObject:(PFObject *)parseObject {
    NSDictionary *attributes = [[self entity] attributesByName];
    NSDictionary *relationships = [[self entity] relationshipsByName];

    //Set all the attributes
    if (self.syncStatusValue != 1) { //Local changes take priority
        for (NSString *attribute in attributes) {
            NSString *className = [[attributes valueForKey:attribute] attributeValueClassName];

            if ([className isEqualToString:@"NSData"]) {
                    PFFile* remoteFile = [parseObject objectForKey:attribute];
                    [self setValue:[remoteFile getData] forKey:attribute]; //CHANGED HERE
                remoteFile = nil; //CHANGED HERE
                continue;
            }

And I run the app again and the [FTASyncHandler syncAll] takes 33.88KB only this time (see the attachment photo:)

3425c36e-b1f1-11e3-9bf9-36838ec2a60c

(Note: in .xcdatamodel, the binary data field, I checked the "Allows External Storage" box to reduce use of memory of core data)

Can you please update the code in FTASync according to the code above?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions