Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timeZonesDB being released #7

Closed
rschmunk opened this issue Sep 10, 2014 · 2 comments
Closed

timeZonesDB being released #7

rschmunk opened this issue Sep 10, 2014 · 2 comments

Comments

@rschmunk
Copy link

I've been giving APTimeZones a tryout. Along with the wrong TZ errors that others have reported for many US locations, I was running into a problem with a crash because of memory being released if I tried to look up more than one location. The problem seems to be that the timeZonesDB property in APTimeZones is not retained and was getting released between lookups.

In the importDataBaseFromFile method, the DB array is created using

NSArray *timeZones = [NSJSONSerialization JSONObjectWithData:jsonData
                                                    options:NSJSONReadingAllowFragments
                                                    error:&error];

I fixed the crashing problem by changing that to

NSArray *timeZones = [[NSJSONSerialization JSONObjectWithData:jsonData
                                                    options:NSJSONReadingAllowFragments
                                                    error:&error] retain];

Also, it looks to me like there is another potential memory bug in the APTimeZones class in the closesZoneInfoWithLocation method. Memory for a zoneLocation object is allocated every time through the loop,

    CLLocation *zoneLocation = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];

but is never released.

@Krivoblotsky
Copy link
Contributor

APTimeZones requires ARC, and seems to be your are not using it. Just switch it to use ARC, and you will get rid of all crashes and memory issues. I will update the documentation to point on this.

@rschmunk
Copy link
Author

Ah, that makes sense, and also explains some other oddities that I ran into elsewhere in the APTimeZones class. And as it was, I later realized I was putting that retain I added in the wrong place.

Thanks for the fast response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants