I have just started learning memory management and I have some questions.
I am implementing a custom camera
var captureSession = AVCaptureSession()
Do I need to put a weak reference (
weak var captureSession = AVCaptureSession()
) to this or will it get deallocated automatically once I move to another view controller which is not using the above resource? I am currently stopping the captureSession inviewDidDisappear
What benefit will I get by adding
weak self
in the following task?URLSession.shared.dataTask(with: url!) { [weak self](data, response, error) in { }
I usually add various observers to textfield, network check and remove them in
viewDidDisappear
. Do they get completely deallocated from memory or do I have to do something extra above this?