I have an IBOutlet-wired NSView object named displayView, where I add 3 to 4 NSImageView objects as subViews. Whenever the user resizes the application window, this displayView guy needs to be updated. When the user closes the application window with the red close button, the application hides it with
NSApp.hide(nil)
. When the user clicks on the doc icon of the application, the application unhide the window. When it does, the application will remove all sub views like
for sub in displayView.subviews {
sub.removeFromSuperview()
}
But the application leaks the memory a big time. If I repeat the sequence of hiding and unhiding the application window 5 to 6 times, its memory consumption can reach 500 MB. I know what to do, but my question is why the application keeps mounting its leak even though it removes its all sub views whenever the application is back to life from hiding itself and updates the displayView guy.
Muchos thankos.