objective c - Understanding Instruments and Memory Management -
i'm in need of understanding how memory managed in objective c. know basics, if create , own it, must release yourself. however, when gets code such as:
self.storedict = [nsmutabledictionary dictionarywithcontentsoffile:plistpath2]; do own this? must release memory?
self.storedict = [nsmutabledictionary dictionarywithcontentsoffile:plistpath2]; //73.3% leak totalcharacters = [storedict count]; tagcounter = 1; dictkeyarray = [[storedict allkeys] mutablecopy]; //13.3% leak when instruments puts bunch of percentages next highlighted leaks, tell me? tell me size of leak relative total amount of memory leaked?
, 1 last thing.. normal amount of allocated memory continuously rise? or should stabilize somewhere? help! appreciated!
in cases, own objects returned methods names begin "alloc", "new", "copy", or "mutablecopy". of course, own send -retain. exceptions these rules should called out in documentation non-conforming methods.
instruments attributes leak line object created. however, that's not code leaked object. if pointer object passed other code , code did not balance retains , releases, code responsible leak. instruments can show history of retains , releases specific object, , you'll have review see code not discharging ownership responsibilities properly.
also, if object owned object , it's second object leaked, owned have leaked "transitively" were. so, higher-level objects have leaked before trying track down low-level objects have leaked. often, objects have leaked fewer instances root of graph of leaked objects.
whether normal memory keep rising or stabilize, depends little. usually, memory usage should stabilize. however, if app doing more , more, may normal memory usage keep increasing. example, if app receiving data on network , accumulating results so, memory usage rise more data arrives. if doesn't stop @ reasonable point, that's problem. on ios device, system kill it.
Comments
Post a Comment