itsniper / FTASync

Allows you to sync CoreData entities with a Parse backend.
MIT License
311 stars 59 forks source link

Saving memory #26

Open ericcheungidea opened 10 years ago

ericcheungidea commented 10 years ago

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?

Alydyn commented 10 years ago

Pretty sure Justin has abandoned the project, at least for the time being.

You may have better luck with one of the forks. Regards, Aaron

ericcheungidea commented 10 years ago

ic.... thanks for reminding me

fatuhoku commented 10 years ago

The most advanced fork is probably https://github.com/8020world/FTASync — but there's no issues section.

itsniper commented 10 years ago

Thanks @ericcheungidea for the more optimal code. The best way to submit changes like this are via a Pull Request linked to this issue.

Unfortunately I've not had any time to make updates on this project for a while. I've worked for 3 different startups since I wrote FTASync, so it's been a little crazy! I'm hoping to have some time over the summer to pull in some updates from some of the forks, but for now I'd recommend grabbing one of the other forks and using that.

ericcheungidea commented 10 years ago

Thanks for attention from all of you. I will fork and update it if I have time as I am busy recently...

Nice to hear @itsniper has so many opportunities after you wrote FTASync!