David
David

Reputation: 157

How should I solve this error: Thread 1: EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=650 MB, unused=0x0)?

I am trying to run my app which uses this GitHub project: https://github.com/PaoloCuscela/Cards/wiki/Overview

But when I run my app on my iPhone 6, it crashes and gives me the error in the title.

I've written 28 of these in my viewDidLoad function and the app runs fine on the simulator.

 let tennisCard = CardHighlight(frame: CGRect(x: 67, y: 3362, width: 250, height: 300))
           tennisCard.title = "Exercise 11"
           tennisCard.itemTitle = "Tennis"
           tennisCard.backgroundColor = UIColor(red: 0/255, green: 255/255, blue: 79/255, alpha: 1)
           tennisCard.buttonText = "See"
           tennisCard.itemSubtitle = ""
           tennisCard.tintColor = UIColor.black
           tennisCard.textColor = UIColor.black
           tennisCard.icon = UIImage(named: "Tennis")
           let tennisVC = storyboard?.instantiateViewController(withIdentifier: "TennisCardContent")
                tennisCard.shouldPresent(tennisVC, from: self)
                scrollView.addSubview(tennisCard)

Upvotes: 7

Views: 19855

Answers (1)

Felix Tra
Felix Tra

Reputation: 142

It seems like your app uses to much resources.

First of all, check if your assets have big file sizes, and if that is the case resize them to a lower resolution.

Also loading all of these (mostly hidden below the visible area) views into the scroll view at once is very memory inefficient. Try using a table view or collection view that only loads these views when visible. This could also help you get rid of code duplication

Upvotes: 11

Related Questions