Avicii4ever
Avicii4ever

Reputation: 139

How to locate memory leak causes only by memory address in swift?

I have some memory leaks in my project, it seems like a closure or cycle reference issue, but I only have memory address.

How can I find certain function or closer that causes memory leaky by memory address?

enter image description here

---------Update ---------

Thanks to @DarkDust, the info of memory address is under inspector tab.

enter image description here

Upvotes: 1

Views: 1431

Answers (1)

DarkDust
DarkDust

Reputation: 92384

Edit your scheme, select the "Run" section on the left and then the "Diagnostics" tab. Here, enable "Malloc Stack Logging" (you may need to disable runtime sanitizers if this option is greyed out).

Then run your app again. You can now view a stack trace generated at the time a specific memory area was allocated in the inspector.

See for example this tutorial or this one.

Upvotes: 3

Related Questions