开发者

iphone memory allocations and leaks

How to solve memory allocation 开发者_StackOverflow社区in ios ?give me the right way to solve memory issues and memory leaks.


The best way to avoid these Memory issues is through proper coding. Just go through the Apple reference on Memory Management.

You only release or autorelease objects you own.

You take ownership of an object if you create it using a method whose name begins with “alloc”, “new”, “copy”, or “mutableCopy” (for example, alloc, newObject, or mutableCopy), or if you send it a retain message.

You use release or autorelease to relinquish ownership of an object. autorelease just means “send a release message in the future” (specifically: when the used autorelease pool receives a drain message—to understand when this will be, see “Autorelease Pools”).


Without more info all I can say is...

  • Release anything you init and/or alloc that is not autoreleased.
  • Delete anything that you call "new" on
  • free any data you malloc
  • Use Instruments to diagnose where your leaks are occuring.
  • Release anything you retain

release anything you init that is not autoreleased.


@Nipin, For solving memory issues, you'll have to release each object that you're allocating... ie, use [yourObject release]; for each object you call alloc method... Also, unload any textures that you're using [texturename unload];

[texturename release];

Do all these when you no longer requires those objects or textures and in most cases it can be where you exit from the scene...


follow the below link memory management

another link is small guide for quick point small article

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜