FTASync icon indicating copy to clipboard operation
FTASync copied to clipboard

Saving memory

Open ericcheungidea opened this issue 10 years ago • 5 comments

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?

ericcheungidea avatar Mar 22 '14 18:03 ericcheungidea

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

Alydyn avatar Mar 25 '14 11:03 Alydyn

ic.... thanks for reminding me

ericcheungidea avatar Mar 25 '14 16:03 ericcheungidea

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

fatuhoku avatar Mar 27 '14 14:03 fatuhoku

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.

itsniper avatar Mar 28 '14 05:03 itsniper

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!

ericcheungidea avatar Apr 01 '14 10:04 ericcheungidea