memory management question -- releasing an object which has to be returned
<p>I have an NSMutableArray called playlist. This is in a method called getAllPlaylists. The code is something like this:</p>

<pre><code>-(NSMutableArray *)getAllPlaylists
{
    //playlist is an instance variable
     playlist = [[NSMutableArray alloc] init]; //memory leak here
    ...
    //some code here which populates the playlist array
    [playlist addObject: object1];
    ...
     return playlist;
}
</code></pre>

<p>The array allocation step of playlist is causing a memory leak. In such a scenario where can i release this array? Or can i avoid allocation n initialization of playlist here by doing something else? Any help will be greatly appreciated!!</p>
