tags:

views:

60

answers:

2
+1  A: 

I'm surprised it works at all. You cast an NSString to an NSMutableDictionary which seem a bit odd. If it is correct, the leak might just be a false positive due to the unusual code.

I don't see a leak in feedString but I do see one in cardTypeDTO. You've commented out the release but this is not correct.

Stephen Darlington
what you mean by the "leak might just be a false positive due to the unusual code." and other thing is i commented that line because i'm having a autorelase pool there, i changed the setValu method to SetObject but no luck.
Sam
The autorelease pool is irrelevant as cardTypeDTO is not autoreleased.
Stephen Darlington
By false positive I mean that your code may be confusing Instruments into thinking there's a leak in feedString when there isn't. But you don't show how feedString is defined so it's difficult to be sure.
Stephen Darlington
thanks for the all the support,i'm wondering about this line "The autorelease pool is irrelevant as cardTypeDTO is not autoreleased. " can you explain about it,
Sam
this how i get the Feed string,http://pastebin.com/DsmSmmWg
Sam
I think you need to read up a little more on memory management in Objective C: http://developer.apple.com/iphone/library/documentation/General/Conceptual/DevPedia-CocoaCore/MemoryManagement.html
Stephen Darlington
A: 

You really need to review iPhone memory rules. For example

+(NSString *) urlDecode: (NSString *) url
{
   NSString *result=[url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
   return [result autorelease];
}

The result of stringByReplacingPercentEscapesUsingEncoding is already autoreleased and you are autoreleasing it again.

On the return, you do this:

[cardTypeDTO setImageURL:[[CommonUtility urlDecode:[cardDetail objectForKey:@"imageURL"]] retain]]

is setImageUrl a synthesized retain @property? If so, it already calls retain.

cardTypeDTO has retainCount 1 and then is added to a dictionary that retains it (setValue calls setObject, which sends retain).

I wrote this, which might help:

http://loufranco.com/blog/files/managing-memory-iphone.html

There is also a link there to another good explanation.

Lou Franco