Search code examples
iphoneobjective-cxcodeinstruments

Instruments is showing leaks for auto-released dictionaries, strings


Auto released leaks?

Can't figure out what's going on here. +array and +dictionary are supposed to be autoreleased correct? Why then is instruments insisting I have memory leaks there?

So I set dictionaries for about 12 or so objects, and then eventually I set the property self.messageObjectsForPage = messageObjects;

Not sure what's happening here.


Solution

  • What I feel is that Instruments is not very precise yet on what it calls as Leaks.

    I have been developing apps for more than an year now but I have faced similar issues many times.

    Also you are correct that +array and +dictionary creates autoreleased objects.

    So as far as the app works fine and doesn't give any memory warnings on device, you can ignore this minor leaks and search for other obvious leaks if they exist.

    This is what Apple has to say about NSDictionary's +dictionary method

    This method is declared primarily for use with mutable subclasses of NSDictionary.
    
    If you don’t want a temporary object, you can also create an empty dictionary using alloc... and init.
    

    So this assures that it is autoreleased object.

    Hope this helps you.