iOS frequently opens album crashes: alassetslibrary Error-"Too many contexts. No space in Contextlist. "

Source: Internet
Author: User

iOS frequently opens album crashes: alassetslibrary Error-"Too many contexts. No space in Contextlist. "

http://stackoverflow.com/questions/13480611/ Has-anyone-experienced-crashes-when-using-alassetslibrary-in-a-background-thread

Reason:

Because of frequent calls

[[alassetslibrary alloc] init]

Even if your album is closed, but if you call this phrase frequently, in the ARC mode, it is estimated that iOS is not emptying memory in time,

will lead to "Too many contexts. No space in Contextlist. "

Therefore, the workaround is to use a singleton call.

+ (Alassetslibrary *) defaultassetslibrary{    static dispatch_once_t pred = 0;    static alassetslibrary *library = nil;    Dispatch_once (&pred, ^{        library = [[Alassetslibrary alloc] init];    });    return library;}

 

Or I used the Dbcamera library, which has provided a way to directly use the line.

Alassetslibrary *sharedlibrary = [[Dblibrarymanager sharedinstance] defaultassetslibrary];        [Sharedlibrary enumerategroupswithtypes:alassetsgroupall                                     usingblock:^ (alassetsgroup *group, BOOL *stop)         {             if (group)             {                 NSString *namestr = [group valueforproperty:alassetsgrouppropertyname];                          }                             failureblock:^ (Nserror *error)         {             NSLog (@ "Failureblock");         }];

  

It's not so easy to crash after the test.

iOS frequently opens album crashes: alassetslibrary Error-"Too many contexts. No space in Contextlist. "

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.