actionscript-3 - 删除 AS3 中的父级 : Does this free the memory used by all the children?

标签 actionscript-3 removechild displayobject

我正在制作一个相当大的闪存项目,因此我担心内存使用情况。在应用程序的每个部分的末尾,我删除了保存内容的总体父元素。虽然这会删除父级,但这是否也会释放其中包含的每个子级的内存,或者我应该在删除父级之前运行迭代来删除这些子级?

如果我没有表达我想要的内容,我会给出更多解释:

addChild(movie1);
movie1.addChild(movie2);
movie1.addChild(movie3);

通过使用此代码:

removeChild(movie1);

它是否从内存中删除 movie2 和 movie3 或者它们仍然存储,只是取消链接?

最佳答案

如果 movie2movie3 不再被另一个对象引用,则应该对它们进行垃圾回收。这同样适用于movie1

来自Creating visual Flex components in ActionScript :

To programmatically remove a control, you can use the removeChild() or removeChildAt() methods. You can also use the removeAllChildren() method to remove all child controls from a container. Calling these methods does not actually delete the objects. If you do not have any other references to the child, Flash Player includes it in garbage collection at some future point. But if you stored a reference to that child on some object, the child is not removed from memory.

关于actionscript-3 - 删除 AS3 中的父级 : Does this free the memory used by all the children?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3734228/

相关文章:

JavaScript:如何从节点中删除标签?

java - 删除 @ManyToMany 关联期间发生 Hibernate 异常

android - 获取与 Android 查询的完整对话

css - 关于 CSS 定位的建议

node.js - 如何在node.js中顺序显示文件夹的所有图像

apache-flex - mxmlc 中的静态链接运行时共享库

actionscript-3 - flash as3 - startDrag、stopDrag 的事件监听器?

c# - 从一组相似节点中删除一个节点/元素

actionscript-3 - 灵活的本地鼠标位置

android - Flex 移动项目 : Numeric Keyboard