iOS内存问题

时间:2013-06-10 13:07:48

标签: objective-c cocoa-touch memory-management

我是ARC编程的新手,并且一直在寻找iOS中的内存崩溃以及ARC如何适应。我明白了ARC,但我得到了很多“收到的内存警告”崩溃了。

然后我看到一篇关于使用@autoreleasepool的帖子,所以我把它放在一边:

@autoreleasepool {
        for (i = 0; i < [results count]; i++) {
            // create new object CustomAnnotation
            myAnn = [[CustomAnnotation alloc] init];
            // set the lat and long of the object
            location.latitude = (double)[[[results objectAtIndex:i] objectForKey:@"lat"] doubleValue];
            location.longitude = (double)[[[results objectAtIndex:i] objectForKey:@"long"] doubleValue];
            // set properties of the object
            myAnn.coordinate = location;
            myAnn.title = [[results objectAtIndex:i] objectForKey:@"title"];
            myAnn.subtitle = [[results objectAtIndex:i] objectForKey:@"strap"];
            myAnn.pinId = [[results objectAtIndex:i] objectForKey:@"id"];
            myAnn.url = [[results objectAtIndex:i] objectForKey:@"link"];
            myAnn.dateTime = [[results objectAtIndex:i] objectForKey:@"timestamp"];

        // add the object to the array locations
        [locations addObject:myAnn];
        }
    } // end autoreleasepool

我想象的是相当沉重的记忆。我已经查看了内存跟踪器的内容,内存级别似乎在不退缩的情况下上升和上升。我的.h中有什么东西可以保留记忆吗?

#import <Social/Social.h>
#import <Accounts/Accounts.h>
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
#import "FilterViewController.h"

@class FilterViewController;

@interface FirstViewController : UIViewController
{
    NSArray *results;
    UIActivityIndicatorView *spinner;
    NSMutableData *data;
    UILabel *sliderValue;
    NSString *whatDay;
    NSString *whatTime;
    NSDate *passedData;
    NSString *datePicker;
    SLComposeViewController *mySLComposerSheet;
}

@property (strong) FilterViewController *filterViewController;
@property (weak, nonatomic) IBOutlet MKMapView *mapView;

@property(strong, nonatomic) NSString *datePicker;

@property(nonatomic, retain) NSDate *passedData;

@property int selectedTime;

- (IBAction)designworks:(id)sender;
- (IBAction)searchOptions:(id)sender;
- (IBAction)refreshMap:(id)sender;
- (IBAction)twitterButton:(id)sender;
- (IBAction)postFacebook:(id)sender;

@end

很抱歉这样一个可以讨论的问题,我正在学习,内存管理的速度很慢!

编辑:内存配置文件:

memory profile

0 个答案:

没有答案
相关问题