Wowza Community

Is it necessary to remove manually the IMediaStreamActionNotify from the stream?


I have found an example in which an instance of IMediaStreamActionNotify is attached to a stream. In that code there is a code snippet like this:

public void onStreamDestroy(IMediaStream stream) {
		IMediaStreamActionNotify actionNotify = null;
		WMSProperties props = stream.getProperties();
			actionNotify = (IMediaStreamActionNotify)stream.getProperties().get("streamActionNotifier");
		if (actionNotify != null)

Question: if the stream is going to be destroyed, is it really necessary to manually remove this listener? I have never seen any API where this was necessary in order to prevent memory leak. In the generated javadoc that is usually referred to as server side API documentation, I haven’t found any info about this. :slight_smile:

Can you tell it to me? Thanks!


It best practice where possible to remove any objects used in a connection prior to it shutting down. Keeping track of objects used is an important element when writing any code, regardless of language used.


lol good question :smiley: u probably can see memory leak if it doesn’t. Waiting for ur finding!

Ok, so if we are supposed to do this, that means behind the scenes the IMediaStream object is not garbage collected along with its properties when the client is disconnected. Otherwise we could rely on the GC. Does that mean it’s not safe to expect that a fresh IMediaStream’s properties might contain outdated garbage data from previous cycles?