Xcode Zombies - Huge memory leaks

Context it’s everything. where do you run this code from? obviously if this runs endlessly w/o ARP, noting will release auto-released references. So that’s probably “as designed”.

It’s run in loop and after I call removeAllObjects on NSMutableArray and I exit from procedure, so both, allocated objects and array is out of scope. It should be freed and it’s in Xcode (I did same code in Xcode), but is not. Same class but with byte array is now released, but not with string variable. All procedure looks same.
I know that in main loop allocated objects may retain in memory, that’s why autoreleasepool is used.
I’ll check my project where I download 0,5Mb every 15 sec. and remove all data after use. There I found this problem.

[EDIT]

When I run ooo() method (which create 10000 objects and add to array) on button action, then memory is freed, so here is working good. So must be something wrong yet. I’ll try to spot it, because my app, do not release memory. It still grown. So with ARC I have no control how to release array. My code works in dispatch_async block. Anyway I must spot it because maybe is wrong design from my side or not, no idea. It must work :slight_smile:

Let’s clarify. If I have global NSMutableArray where I add objects, use them (data), receive next portion of data, I clear that array to and copy new data, so old objects are out of scope and should be freed, right?

b.r.

I’ll need a full project to judge this. The code snippet itself is not enough to make a case.

Okay I think all is clear now. After deeeeeeep analize I realized, that I do long running work in dispatch_async where is endless loop (till get stop singal) and it’s act as BIG loop. I envelope it with autoreleasepool and now ALL is freed :slight_smile: There are some strange leaks with semaphores (not regular), but I have no time now to trace it (will check in free time). So I can definitely say, that it’s fixed!!
I should redesign my long running work with serial queues and timers to fire server task every 15 sec. instead use long running loop, but it’s for later and small lesson for future :smile:
Thank You for effort and patience and as always - GOOD JOB! :+1:

b.r.