Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference Memory Leak and a Zombie?

I am working on a ARC based project . I have never worked on Non ARC based project .Recently I

came across a zombie in my ARC enabled project.As far as I understood there wont be memory

leaks in ARC , as the objects will be deallocated automatically.But I came across a zombie

saying "message passed to a deallocated instance".My confusion is is a Memory Leak equivalent

to a Zombie. If that is the case then Memory Leak occur in ARC too ? Any help ?

like image 824
Raj Avatar asked Oct 01 '12 04:10

Raj


People also ask

What does memory leak mean in games?

Despite having adequate RAM and not running resource-intensive software, there can be another situation where all available RAM gets used and performance degrades. This is known as a memory leak, and it happens when software fails to manage the available RAM correctly.

Is memory leak a bug?

Description. Memory leaks are a class of bugs where the application fails to release memory when no longer needed. Over time, memory leaks affect the performance of both the particular application as well as the operating system. A large leak might result in unacceptable response times due to excessive paging.

How serious are memory leaks?

Memory leaks may not be serious or even detectable by normal means. In modern operating systems, normal memory used by an application is released when the application terminates. This means that a memory leak in a program that only runs for a short time may not be noticed and is rarely serious.

What is difference between memory leak and dangling pointer?

Generally, daggling pointers arise when the referencing object is deleted or deallocated, without changing the value of the pointers. In opposite to the dangling pointer, a memory leak occurs when you forget to deallocate the allocated memory.


2 Answers

"Zombies" in Objective-C parlance are the opposite of leaks. A leak is a bit of allocated memory that you no longer have any references to, so you can't free it. A zombie is an object that has been deallocated, but references to it still exist and messages are still being sent to it (which can lead to all sorts of unpredictable behavior).

like image 169
Chuck Avatar answered Oct 12 '22 01:10

Chuck


There are several possibilities and it's hard to know what's going on without seeing code. The "message passed to a deallocated instance" error means that you have a pointer that points to where an object had been, but has since been deallocated. This can and does still happen with ARC. It can happen because you have some non-ARC code (or perhaps Core Foundation stuff) interacting with ARC code and things are going awry at the hand-offs. It can also happen because while ARC picks the correct points in time to release objects nearly every single time, it's not perfect (usually there are ways to work around these instances).

like image 20
Isaac Avatar answered Oct 12 '22 01:10

Isaac