0

I am navigating from root view controller to the second controller which have ARSCN View now when I pop the controller from the stack it does not deallocating the memory and a huge memory leakage occurs when you move back and forward many times

Darshan
  • 2,272
  • 3
  • 31
  • 43
Muhammad Iqbal
  • 109
  • 1
  • 9
  • check for strong variables and closures in vcs which must be deallocated – Alexandr Kolesnik Dec 10 '19 at 13:27
  • 1
    Possible duplicate of https://stackoverflow.com/questions/21398934/why-arc-is-not-deallocating-memory-after-popviewcontroller – MS_iOS Dec 10 '19 at 13:37
  • there are no strong reference even an empty view controller increases memory after pushing and popping again and again ARC is not managing memory by itself I think there is a way to deinit your viewcontroller in hoping – Muhammad Iqbal Dec 10 '19 at 14:12

2 Answers2

0

while popping a view controller from stack remove all the subview by - view.subviews.forEach { $0.removeFromSuperview() } and also deinit your resource like objects that are used in that view controller -tested and solved by myself

Muhammad Iqbal
  • 109
  • 1
  • 9
0

It's hard to say what's going on without seeing your code but here are a few suggestions:

  • If you are instantiating the second UIViewController if you are referencing it from the first UIViewController you need to make sure you're doing it in such a way you're not causing a reference cycle
  • You should consider using segue instead of instantiation, you should only use instantiation if you have a specific reason to do so
  • If you are using segue, you should use unwind segue instead of pop to return to the previous UIViewController
CSjunkie
  • 535
  • 2
  • 8
  • 28