ios – Why is my app crashing on an iPad due to low memory?


Newbie to coding.
I’m at the stage of testing part of my app on an iPad. It works without dramas in the simulator (which I understand why). When I run it on an iPad, it crashes after a couple of cycles through any random image gen. Leak tests have come back fine. My concern is that it looks like it continuously opens new arrays without closing the previous one that just ran.

Leak test results

Not quite sure of how to precede from here. I have tried to research some processes to see if I can solve it but nothing has worked, unfortunately.

I would very much appreciate if anyone had the time to test this and see if there is a solution.

import Foundation
import UIKit

class Numbers0to30ViewController: UIViewController {
    
    @IBOutlet weak var numbersImageView: UIImageView!

    var numbersImage = 0
    var numbersArray = [ ]
    //array consists of 31 image literals

    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        numbersArray.shuffle()
        
    }
    
    @IBAction func nextButtonPressed(_ sender: UIButton) {
        
        numbersImage += 1
        
        if numbersImage == 31 {
            
            DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
                self.performSegue(withIdentifier: "goToNumbers30Reset", sender: self)
            }
    //segue goes to a separate UIView with a 'reset' and 'menu' button. 'Reset' goes back to this UIView to repeat the process, 'menu' goes back to the main UIView.
        }
    }

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img