0
votes

I've built a video viewer that is a Safari plugin that displays video from networked devices. The viewer reads bitmap images, prepares them, and sets them on the NSImageView object as follows:

NSBitmapImage *bmImg = [[NSBitmapImage alloc] initWithBitmapDataPlanes: . . .]
NSImage *img = [[NSImage alloc] init];
[img addRepresentation:bmImg];

The image is added to the NSImageView via "setImage" on the main thread. The video displays fine.

My question is, shouldn't the act of setting the next image via "setImage" cause the prior image and its associated bitmap image to be released and subsequently freed?

Do I need to perform the [img release] on the alloc'd image myself?

Do I need to remove the image rep from the img and release it also?

Thanks in advance.

2
Show us your real code. There is no such thing as NSBitmapImage; I assume you mean NSBitmapImageRep. Also, format it as code rather than mixed in with the rest of the question.Mike Abdullah

2 Answers

0
votes

You need to actually go and read the Cocoa memory management guide. It will answer all your questions.

0
votes

I actually did read the Cocoa memory management guide prior to posting here. It was not a very obvious solution though the guide did help once I read it again.

The solution was to release the NSImage and NSBitmapImageRep instances after sending it to "setImage" on NSImageView.