Do loops and convenience methods cause memory peaks with ARC?

前端 未结 2 408
终归单人心
终归单人心 2021-02-01 08:54

I\'m working with ARC and seeing some strange behavior when modifying strings in a loop.

In my situation, I\'m looping using NSXMLParser delegate callbacks, but I see t

2条回答
  •  一向
    一向 (楼主)
    2021-02-01 09:13

    You are polluting the autorelease pool with tons and tons of autoreleased objects.

    Surround the internal part of the loop with an autorelease pool:

    for (...) {
        @autoreleasepool {
            ... your test code here ....
        }
    }
    

提交回复
热议问题