MemoryMgmt.pdf
(
345 KB
)
Pobierz
Memory Management Programming Guide
MemoryManagementProgrammingGuide
Performance
2011-03-24
AppleInc.
©2011AppleInc.
Allrightsreserved.
exclusionmaynotapplytoyou.Thiswarrantygives
youspecificlegalrights,andyoumayalsohave
otherrightswhichvaryfromstatetostate.
Nopartofthispublicationmaybereproduced,
storedinaretrievalsystem,ortransmitted,in
anyformorbyanymeans,mechanical,
electronic,photocopying,recording,or
otherwise,withoutpriorwrittenpermissionof
AppleInc.,withthefollowingexceptions:Any
personisherebyauthorizedtostore
documentationonasinglecomputerfor
personaluseonlyandtoprintcopiesof
documentationforpersonaluseprovidedthat
thedocumentationcontainsApple’scopyright
notice.
TheApplelogoisatrademarkofAppleInc.
Nolicenses,expressorimplied,aregranted
withrespecttoanyofthetechnologydescribed
inthisdocument.Appleretainsallintellectual
propertyrightsassociatedwiththetechnology
describedinthisdocument.Thisdocumentis
intendedtoassistapplicationdevelopersto
developapplicationsonlyforApple-labeled
computers.
AppleInc.
1InfiniteLoop
Cupertino,CA95014
408-996-1010
Apple,theApplelogo,Carbon,Cocoa,
Instruments,Mac,MacOS,Objective-C,and
XcodearetrademarksofAppleInc.,registered
intheUnitedStatesandothercountries.
IOSisatrademarkorregisteredtrademarkof
CiscointheU.S.andothercountriesandisused
underlicense.
EventhoughApplehasreviewedthisdocument,
APPLEMAKESNOWARRANTYORREPRESENTATION,
EITHEREXPRESSORIMPLIED,WITHRESPECTTO
THISDOCUMENT,ITSQUALITY,ACCURACY,
MERCHANTABILITY,ORFITNESSFORAPARTICULAR
PURPOSE.ASARESULT,THISDOCUMENTIS
PROVIDED“ASIS,”ANDYOU,THEREADER,ARE
ASSUMINGTHEENTIRERISKASTOITSQUALITY
ANDACCURACY.
INNOEVENTWILLAPPLEBELIABLEFORDIRECT,
INDIRECT,SPECIAL,INCIDENTAL,OR
CONSEQUENTIALDAMAGESRESULTINGFROMANY
DEFECTORINACCURACYINTHISDOCUMENT,even
ifadvisedofthepossibilityofsuchdamages.
THEWARRANTYANDREMEDIESSETFORTHABOVE
AREEXCLUSIVEANDINLIEUOFALLOTHERS,ORAL
ORWRITTEN,EXPRESSORIMPLIED.NoApple
dealer,agent,oremployeeisauthorizedtomake
anymodification,extension,oradditiontothis
warranty.
Somestatesdonotallowtheexclusionorlimitation
ofimpliedwarrantiesorliabilityforincidentalor
consequentialdamages,sotheabovelimitationor
Contents
AboutMemoryManagement 7
AtaGlance 7
GoodPracticesPreventMemory-RelatedProblems 8
UseAnalysisToolstoDebugMemoryProblems 8
MemoryManagementPolicy 11
BasicMemoryManagementRules 11
ASimpleExample 11
UseautoreleasetoSendaDeferredrelease 12
YouDon’tOwnObjectsReturnedbyReference 13
ImplementdealloctoRelinquishOwnershipofObjects 13
CoreFoundationUsesSimilarbutDifferentRules 14
PracticalMemoryManagement 15
UseAccessorMethodstoMakeMemoryManagementEasier 15
UseAccessorMethodstoSetPropertyValues 16
Don’tUseAccessorMethodsinInitializerMethodsanddealloc 16
UseWeakReferencestoAvoidRetainCycles 17
AvoidCausingDeallocationofObjectsYou’reUsing 18
Don’tUsedealloctoManageScarceResources 19
CollectionsOwntheObjectsTheyContain 20
OwnershipPolicyIsImplementedUsingRetainCounts 20
UsingAutoreleasePools 23
AboutAutoreleasePools 23
UseLocalAutoreleasePoolstoReducePeakMemoryFootprint 24
AutoreleasePoolsandThreads 25
ScopeofAutoreleasePoolsandImplicationsofNestedAutoreleasePools 25
GarbageCollection 26
DocumentRevisionHistory 27
2011-03-24 | © 2011 Apple Inc. All Rights Reserved.
3
4
2011-03-24 | © 2011 Apple Inc. All Rights Reserved.
Figures
PracticalMemoryManagement 15
Figure1 Anillustrationofcyclicalreferences 17
2011-03-24 | © 2011 Apple Inc. All Rights Reserved.
5
Plik z chomika:
Gaarr
Inne pliki z tego folderu:
Xcode_Quick_Start_Guide.pdf
(6477 KB)
Learn Objective-C on the Mac.pdf
(5172 KB)
CocoaDrawingGuide.pdf
(4457 KB)
Dashcode_UserGuide.pdf
(2590 KB)
Collections.pdf
(907 KB)
Inne foldery tego chomika:
Zgłoś jeśli
naruszono regulamin