Gourav Joshi
Gourav Joshi

Reputation: 2419

How we can check that certain object is released memory

As I start working in swift, I am curious in memory mgmt. As we all know that during any object creation or assignment of data into that object it takes memory. How can we check that a particular object has released the memory. I used xcode memory report to see memory status and fluctuations.

Here is a sample of images:

enter image description here

enter image description here

How can release memory if I already set nil into the objects.

Upvotes: 10

Views: 4178

Answers (3)

shpasta
shpasta

Reputation: 1933

Some objects are very small and it could be difficult to see in Memory profiling which one is released. This tool is helpful for finding memory leaks in an app. To check was some object released from memory or wasn't you can setup breakpoints or logs in dealloc() method for objective c and in deinit() method for swift.

Upvotes: 3

user6943228
user6943228

Reputation: 56

Using instruments checking for leaks or allocations is the recommended way.

You can also set breakpoints or add logs to the dealloc method.

Upvotes: 2

Vikram Parimi
Vikram Parimi

Reputation: 777

Use instruments to track the lifecycle of an object than just Xcode because it gives you the allocation details at much higher level.

Check out the answer at https://stackoverflow.com/a/14891837/5133769. Though it was explained with old instruments it still works.

Upvotes: 5

Related Questions