資源描述:
《Advanced Memory Management Programming Guide.pdf》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在學(xué)術(shù)論文-天天文庫。
1、AdvancedMemoryManagementProgrammingGuideContentsAboutMemoryManagement4AtaGlance4GoodPracticesPreventMemory-RelatedProblems5UseAnalysisToolstoDebugMemoryProblems6MemoryManagementPolicy7BasicMemoryManagementRules7ASimpleExample8UseautoreleasetoSendaDefer
2、redrelease8YouDon’tOwnObjectsReturnedbyReference9ImplementdealloctoRelinquishOwnershipofObjects10CoreFoundationUsesSimilarbutDifferentRules11PracticalMemoryManagement12UseAccessorMethodstoMakeMemoryManagementEasier12UseAccessorMethodstoSetPropertyValue
3、s13Don’tUseAccessorMethodsinInitializerMethodsanddealloc14UseWeakReferencestoAvoidRetainCycles15AvoidCausingDeallocationofObjectsYou’reUsing16Don’tUsedealloctoManageScarceResources17CollectionsOwntheObjectsTheyContain18OwnershipPolicyIsImplementedUsing
4、RetainCounts19UsingAutoreleasePoolBlocks20AboutAutoreleasePoolBlocks20UseLocalAutoreleasePoolBlockstoReducePeakMemoryFootprint21AutoreleasePoolBlocksandThreads23DocumentRevisionHistory242012-07-17
5、Copyright?2012AppleInc.AllRightsReserved.2FiguresPracti
6、calMemoryManagement12Figure1Anillustrationofcyclicalreferences152012-07-17
7、Copyright?2012AppleInc.AllRightsReserved.3AboutMemoryManagementApplicationmemorymanagementistheprocessofallocatingmemoryduringyourprogram’sruntime,usingit,andfreeingitwhenyouare
8、donewithit.Awell-writtenprogramusesaslittlememoryaspossible.InObjective-C,itcanalsobeseenasawayofdistributingownershipoflimitedmemoryresourcesamongmanypiecesofdataandcode.Whenyouhavefinishedworkingthroughthisguide,youwillhavetheknowledgeyouneedtomanage
9、yourapplication’smemorybyexplicitlymanagingthelifecycleofobjectsandfreeingthemwhentheyarenolongerneeded.Althoughmemorymanagementistypicallyconsideredatthelevelofanindividualobject,yourgoalisactuallytomanageobjectgraphs.Youwanttomakesurethatyouhavenomor
10、eobjectsinmemorythanyouactuallyneed.AtaGlanceObjective-Cprovidestwomethodsofapplicationmemorymanagement.2012-07-17
11、Copyright?2012AppleInc.AllRightsReserved.4AboutMemoryManagementAtaGlance1.Inthemethoddescribedinthisguide,referredtoas“ma