简体   繁体   中英

JavaScript remove element from memory

I'm trying to do something like limitless scrolling at Facebook. Everything was good but after loading more than 200 posts my browser crashed out (of course it's obvious, I run out of memory). After reading some threads here I'm little bit consused.

My code looks like

let elements = document.querySelectorAll("div[id^=mall_post]");
elements[0].remove();
delete elements[0];

I don't know how to solve it. As I know as GC will delete it if there won't be any references, but how to check which part of code is pointing for it?

使用chrome开发人员工具拍摄堆快照,您可以看到可以优化的内容和正在引用的对象。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM