iOS: Debugging memory leaks for UILabel in swift -


i new profiling , using instruments in xcode. facing of problem of memory leaks in tableviewcell uilabel(calayer). in code tableviewcell have fixed view called bottomview. bottomview may or may not contain uilabel can either directly within bottomview or within subview of bottomview. every time within init method cell check bottomview , remove superview , set nil. reinitialise bottomview (using uiview(frame: )) , switch case follows adds contents bottomview required. i've set other uilabels within cell nil , remove superview in deinit fixed.

my questions , doubts:

  1. is there way particular uilabel created in code allocations screen or other way trace object in code? because i'm still assuming leaks bottomview have variable uilabels. other i've removed other uilabels superview in both cell , viewcontroller containing tableview.
  2. how use "record reference counts" setting in allocation record setting? read @ many places can used address problem i'm facing in 2.
  3. does removing bottomview superview , setting nil each time in init method before initialising new bottomview ensure subviews (be any) gets removed or required search uilabels view.subviews() , set them nil?
  4. i tried using leaks tool although not show red spike in same generations captured in allocation screen. why so? particular leaks captured using leaks pane.
  5. just out of curiosity why uilabels don't deallocated automatically properly?

i'm new debugging , memory management in ios (particularly swift) please excuse me if of questions obvious. or links useful resources regarding of above welcome. please let me know required post other resources relating question.

edit 1: cannot post exact code, i'm doing:

myuitableviewcell.swift: initializecell() { // initializations      if (self.viewwithtag(104) != nil) {         self.viewwithtag(104)!.removefromsuperview()     }     bottomview = uiview(frame: cgrectmake(0, nexty + 8, self.frame.width, 10))     bottomview.tag = 104     self.addsubview(bottomview)      bottomtype = sometype      switch (bottomtype) {         case 1:             somelabel = uilabel()             bottomview.addsubview(somelabel)         case 2:             somelabel = uilabel()             bottomview.addsubview(somelabel)         case 3:             somelabel = uilabel()             bottomview.addsubview(somelabel)             x in array1:                 someview = uiview()                 somenewlabel = uilabel()                 someview.addsubview(somenewlabel)                 bottomview.addsubview(someview)         case 4:             somelabel = uilabel()             bottomview.addsubview(somelabel)             x in array2:                 someview = uiview()                 somenewlabel = uilabel()                 someview.addsubview(somenewlabel)                 bottomview.addsubview(someview)         case 5:             somelabel1 = uilabel()             bottomview.addsubview(somelabel1)             somelabel2 = uilabel()             bottomview.addsubview(somelabel2)             somelabel3 = uilabel()             bottomview.addsubview(somelabel3)         default:             print("unkown type")     }      //some more initializations } 


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -