bootstrap affix插件内存泄漏 [英] bootstrap affix plugin memory leak

查看:115
本文介绍了bootstrap affix插件内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

引导词缀中的这些行插件似乎导致内存泄漏,因为窗口获取对从未发布的词缀实例的引用。

These lines in the bootstrap affix plugin seem to cause a memory leak because the window gets a reference to the affix instance that's never released.

作为一种解决方法我在从DOM中删除附加元素时使用此代码来释放引用:

As a workaround I'm using this code to release the references when removing the affixed element from the DOM:

$(window)
    .off('scroll.bs.affix.data-api')
    .off('click.bs.affix.data-api');

看起来有点hacky-有更好的方法吗?在附加插件文档中没有看到任何内容。

Seems kind of hacky- is there a better way of doing this? Didn't see anything in the affix plugin docs.

推荐答案

我接受了@Carrie Kendall的推荐,并开了一个错误报告......很好地评论了相关的错误报告。

I took @Carrie Kendall's recommendation and opened a bug report... well commented on a related bug report.

https://github.com/twbs/bootstrap/issues/13655

在这种情况下我们需要的是一个关于affix插件的destroy方法和getbootstrap网站上的一些文档,以便在单页应用程序中使用affix插件的人可以避免使用内存在删除附加内容时泄漏陷阱。

What we need in this case is a "destroy" method for the affix plugin and some documentation on the getbootstrap site so that people using the affix plugin in single page apps can avoid the memory leak pitfall when removing their affixed content.

这篇关于bootstrap affix插件内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆