Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBJson - has memory leaks?

Tags:

ios

sbjson

I just cloned the git repository for the SBJson framework and imported the source code into my application. Ran a Static Memory profiler and got a little scared from the results I saw. See the picture

enter image description here

How is this possible? I doubt the developer of this very well known library didn't see this? And indeed, if a run a memory profile it shows memory leaks from this library.

Any ideas? Thx

like image 667
Eugen Avatar asked Mar 25 '12 05:03

Eugen


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.

Do all programs have memory leaks?

Memory leaks are a common error in programming, especially when using languages that have no built in automatic garbage collection, such as C and C++. Typically, a memory leak occurs because dynamically allocated memory has become unreachable.

Do memory leaks cause Segfaults?

No, memory leaks by themselves would not cause a segmentation fault. However, memory leaks usually indicate sloppy code, and in sloppy code other issues, which would cause a segmentation fault, are likely to be present.


1 Answers

It looks like you're using SBJSON in a project that doesn't have ARC enabled. Since ARC removes the need to call release explicitly, code written for ARC (like SBJSON) causes memory leaks when used in a non-ARC project. You should convert your project to use ARC with the built-in refactoring tool (Edit > Refactor > Convert to Objective-C ARC, then explicitly set the -fno-objc-arc compiler flag on any of your source that is not yet ARC-ready.

like image 152
warrenm Avatar answered Sep 22 '22 12:09

warrenm