Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leak in NativePlayerImpl #79

Open
GoogleCodeExporter opened this issue Dec 15, 2015 · 4 comments
Open

Memory Leak in NativePlayerImpl #79

GoogleCodeExporter opened this issue Dec 15, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

As per
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener#Me
mory_issues



    public final native void registerMediaStateHandler(NativeEventCallback _callback) /*-{
    this.addEventListener('progress', function(){  // plugin init complete
    _callback.@com.ritmos.web.ui.common.client.media.NativeEventCallback::onProgressChanged()();
    }, false);
    this.addEventListener('play', function(){  // play started
    _callback.@com.ritmos.web.ui.common.client.media.NativeEventCallback::onStateChanged(I)(1);
    }, false);
......

Will likely produce memory issues.

Original issue reported on code.google.com by ciberki...@gmail.com on 30 Apr 2014 at 11:25

@GoogleCodeExporter
Copy link
Author

I suggest assigning the listeners to class members so they can be removed when 
detached

Original comment by ciberki...@gmail.com on 30 Apr 2014 at 11:27

@GoogleCodeExporter
Copy link
Author

You want something that looks like this:

    public final native void releaseMediaStateHandler()
    /*-{
    this.removeEventListener('loadstart', this.progressListener);
    }-*/;

    public final native void registerMediaStateHandler(NativeEventCallback _callback)
    /*-{
    this.progressListener = function(){  // plugin init complete
    _callback.@com.ritmos.web.ui.common.client.media.NativeEventCallback::onProgressChanged()();
    }; 
    this.addEventListener('loadstart', this.progressListener, false);

And make sure that releaseMediaStateHandler is called onDetach ;)

Original comment by ciberki...@gmail.com on 30 Apr 2014 at 1:22

@GoogleCodeExporter
Copy link
Author

Obviestly change com.ritmos.web.ui.common.client.media with
correct package!

Original comment by ciberki...@gmail.com on 30 Apr 2014 at 1:23

@GoogleCodeExporter
Copy link
Author

Original comment by sbrah...@gmail.com on 9 May 2014 at 5:14

  • Changed state: Accepted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant