Introduction to iOS nszone, Chinese Version

Source: Internet
Author: User
========================================================== =============================== Original blog, reprinted please declare the source of Electronic coffee (original id blue rock) ========================================================== ================================

Nszone is faster than alloc in one sentence.

Http://blog.csdn.net/hector_huang/article/details/7107291 is here to thank the author. Here Ref: http://cocoadev.com/wiki/NSZone

Nszone is Apple's Optimization Method for memory allocation and release. Nszone is not an object; it is an obscure C structure that is used to record information about a series of objects in memory processing (management.
You almost don't need to worry about how your applications manage your own space (zones); cocoa manages it transparently. The default nszone is created when the program is started and all objects are allocated. So why do you want to use your nszone?
If you allocate hundreds of small objects in large quantities, you will find that it makes sense to allocate memory to them. This is because the standard (default) space will be used all the time, and it will become mottled; the process of releasing an object will leave an embarrassing gap for the entire memory. The standard space distributor (Allocator) also knows this, so it tries to prioritize the use of the memory released by the user to fill these gaps, but this method is only available in the space (zone) when it is very large, it will have obvious results.
If you want to allocate memory for a large number of objects, you can create your own space (zone) and tell it not to find those gaps in order to allocate memory for new objects. The Allocator can now jump to the end of the memory allocation to allocate memory for your new object each time, which has a good effect.
In addition, the Allocator can save you time. When the Allocator requests more memory from the operating system, it takes a lot of time for the allocator to find out when the space is filled. A faster time is to request a large block of memory at a time. You can also tell your nszone what to do here.
Nszone also saves you time to release memory. It can release a large amount of allocated memory without disturbing deallocators ). If you use a set to contain a series of objects, you can save time by releasing them at a time instead of being bored.

Related Article

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.