Memory management in ObjC/iPhone
<p>I have question in memory management (objective C). There are two ideal scenario.</p>

<p>============================= scenario 1 ========================================</p>

<pre><code>(void) funcA
{
    MyObj *c = [otherObj getMyObject];
    [c release];
}

-(MyObj *) getMyObject  //(this method is available in other OtherObj.m file)
{
    MyObj *temp = [[MyObj alloc] init];
    // do smothing here
    return temp;
} 
</code></pre>

<p>============================= scenario 2 ========================================</p>

<pre><code>(void) funcA
{
    MyObj *c = [otherObj getMyObject];
}

-(MyObj *) getMyObject  //(this method is available in other OtherObj.m file)
{
    MyObj *temp = [[myObj alloc] init];
    // do smothing here
    return [temp autorelease];
}
</code></pre>

<p>myObj is holding huge chunk of data.</p>

<p>In first scenario I am getting myObj(allocated) from other file so I have to release in my own method. (as per any C/C++ language library ,like strdup will return string duplicate which will realase later by developer not by strdup method).</p>

<p>In second scenario I am getting myObj(allocated) from otherObj.m file so otherObj.m file is responsible to release that allocated memory(mean autorelease)? Is it right?</p>

<p>Please let me know Which scenario is more efficient and valid as per apple memory guidelines.
Please Please don't show me any document link. </p>

<p>Thanks
Manu</p>
