简体   繁体   English

cytoscape.js从内存中删除节点

[英]cytoscape.js Delete Node from Memory

In cytoscape.js, is there a way to actually delete a node from memory completely? 在cytoscape.js中,有没有一种方法可以从内存中完全删除一个节点? I wrote a layout and it consolidates nodes by making new ones and adding them to the graph, but if the layout is re-run, then I need to remove those nodes and recalculate, but there doesn't appear to be a way to allow these nodes to be garbage collected. 我编写了一个布局,并通过制作新的并将其添加到图中来合并节点,但是如果重新运行布局,则需要删除这些节点并重新计算,但是似乎没有一种方法可以允许这些节点被垃圾收集。

If there is a way to do this or is there another way I should approach this? 如果有办法做到这一点,还是我应该采取另一种办法呢?

Thank you. 谢谢。

JS is a garbage collected language, so it suffices to drop all your own references to the node. JS是一种垃圾回收语言,因此只需删除您自己对节点的所有引用即可。 If you remove a node from a graph and don't have any of your own references to it, then the garbage collector will clean it up sooner or later. 如果您从图中删除一个节点并且没有自己的引用,那么垃圾收集器将早晚清理它。

See also https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management 另请参阅https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Memory_Management

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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