does this C++ function produce a memory leak

If, in a function, I have the following code: someClass *x = new object(); x = nullptr; is this a memory leak? Or, is the memory reallocated due to its local scope? Thanks! Not sure how to test this on my own. >Solution : This is a memory leak. It is about the clearest example… Read More does this C++ function produce a memory leak

Does closure create a strong reference to an object that is created inside closure scope?

In this example, will vm and targetVC get deinitialized? will it cause a memory leak? loginModule.checkbox.checkboxAction = { [unowned self] in let vm = HomeViewModel() let targetVC = HomeViewController(viewModel: vm) navigationController?.setViewControllers([targetVC], animated: true) } >Solution : Neither vm and targetVC are captured, because they’re defined with the closure. They like any ol’ local variable. vm… Read More Does closure create a strong reference to an object that is created inside closure scope?