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 the once()/off(). Event not unbound #3001

slenz opened this issue Feb 11, 2019 · 1 comment


None yet
2 participants
Copy link

commented Feb 11, 2019

  • Framework7 version: 3.6.6 (and 4.0.1 seems have that bug also)
  • Any platform

Describe the bug

Memory leak happens when event bound with once() and then unbound with off(). Event handler will not unbound.

To Reproduce

Run the kitchen-sink and watch for the memory allocations in the Chrome devtools. When open and close the "Photobrowser" component several times you will see multiple objects which have pointers to 'swipeBackMove'.

Expected behavior

Event handler unbound and removed

Actual Behavior

I seen this in the framework7-3.6.6/packages/core/js/framework7.js (line 6792)

    function onModalLoaded() {
      // Create Modal
      var modal = app[modalType].create(modalParams);
      modalRoute.modalInstance = modal;
      var hasEl = modal.el;

      function closeOnSwipeBack() {
      modal.on((modalOrPanel + "Open"), function () {
        if (!hasEl) {
          // Remove theme elements

          // Emit events
          modal.$el.trigger(((modalType.toLowerCase()) + ":init " + (modalType.toLowerCase()) + ":mounted"), r
          router.emit(((!isPanel ? 'modalInit' : '') + " " + modalType + "Init " + modalType + "Mounted"), mod
        router.once('swipeBackMove', closeOnSwipeBack);
      modal.on((modalOrPanel + "Close"), function () {'swipeBackMove', closeOnSwipeBack);
        if (!modal.closeByRouter) {

Event bound with router.once('swipeBackMove', closeOnSwipeBack) but failed to unbind in'swipeBackMove', closeOnSwipeBack);

It happens because .once() create a wrapper function which bound with .on() and when'swipeBackMove', closeOnSwipeBack); searches for closeOnSwipeBack() it does not found it and not unbound.


devtools - proj local- f7-framework7-3 6 6-kitchen-sink-core-index html_351

@slenz slenz changed the title Memory leak in the once()/off() events and event not unbound Memory leak in the once()/off(). Event not unbound Feb 11, 2019

nolimits4web added a commit that referenced this issue Feb 11, 2019

nolimits4web added a commit that referenced this issue Feb 11, 2019


This comment has been minimized.

Copy link

commented Feb 14, 2019

Fixed in latest 3.x and 4.x, should be better now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.