FTASync
FTASync copied to clipboard
Saving memory
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:)
(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?
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
ic.... thanks for reminding me
The most advanced fork is probably https://github.com/8020world/FTASync — but there's no issues section.
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.
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!