Swift5 MacOS ImageResize memory issue

You can put your whole code that it is inside your loop inside an autoreleasepool:

If you write a loop that creates many temporary objects. You may use
an autorelease pool block inside the loop to dispose of those objects
before the next iteration. Using an autorelease pool block in the loop
helps to reduce the maximum memory footprint of the application.

for i in paths.indices {
    autoreleasepool {
        // all your image resizing code goes here
    }
}

Leave a Comment