Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSCFString Memory Leak

I have been solving a lot of memory leaks but have been unsuccessful in solving this one. There are tons of NSCF memory leaks coming due to [NSCFString substringWithRange:]. I have been checking all the String allocations and have released all of them at appropriate places. The responsible library: Foundation.

Has anyone encountered this problem before? Can anyone suggest me as how I should takle this issue?

Thanks,

Lakshmie

like image 740
Lakshmie Avatar asked May 04 '10 23:05

Lakshmie


People also ask

What is the main cause of memory leaks?

DEFINITION A memory leak is the gradual deterioration of system performance that occurs over time as the result of the fragmentation of a computer's RAM due to poorly designed or programmed applications that fail to free up memory segments when they are no longer needed.

Is memory leak serious?

Very dangerous. Memory leaks in the kernel level lead to serious system stability issues. Kernel memory is very limited compared to user land memory and should be handled cautiously. Memory is allocated but never freed.

Are memory leaks permanent?

Physical or permanent damage does not happen from memory leaks. Memory leaks are strictly a software issue, causing performance to slow down among applications within a given system. It should be noted a program taking up a lot of RAM space is not an indicator that memory is leaking.


2 Answers

General Block-3584 just means a malloc of 3584 bytes. It is not itself a component of any framework. Regardless, judging from info on the web, it appears to be a CFNetwork issue and its not entirely clear that it's a leak -- just that the Leaks tool thinks its a leak. In any case, this one probably isn't your fault and you can ignore it. - Matt

like image 199
Lakshmie Avatar answered Sep 24 '22 18:09

Lakshmie


using the class methods of NSString, such as [NSString stringWithString:@"hi"] will leak, since memory was never allocated - you dont see an alloc in there, ya?. the proper way is:

NSString *temp = [[NSString alloc] initWithString:@"hi"];
myIvarProperty = temp;
[temp release];
like image 23
Papasmurf Avatar answered Sep 23 '22 18:09

Papasmurf