在 AS3 中删除父级:这是否会释放所有子级使用的内存?
我正在制作一个相当大的闪存项目,因此我担心内存使用情况。在应用程序的每个部分的末尾,我删除了保存内容的总体父元素。虽然这会删除父级,但这是否也会释放其中包含的每个子级的内存,或者我应该在删除父级之前运行迭代来删除这些子级?
如果我没有表达我想要的内容,我会给出更多解释:
addChild(movie1);
movie1.addChild(movie2);
movie1.addChild(movie3);
通过使用此代码:
removeChild(movie1);
它是否从内存中删除 movie2 和 movie3 或者它们仍然存储,只是未链接?
I'm making a rather large flash project and so I'm concerned about memory usage. At the end of each section of the application I remove the overarching parent element that holds the content. Although this remove the parent, does this also free up the memory for each of the children contained within this, or should I run an iteration to remove those prior to removing the parent?
I'll give a little more explanation in-case I'm not expressing what I want:
addChild(movie1);
movie1.addChild(movie2);
movie1.addChild(movie3);
By using this code:
removeChild(movie1);
Does it remove movie2 and movie3 from memory or are they still stored, just unlinked?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果
movie2
和movie3
不再被另一个对象引用,则应该对它们进行垃圾回收。这同样适用于movie1
。来自在 ActionScript 中创建可视化 Flex 组件:
If
movie2
andmovie3
aren't referenced anymore by another object, they should be garbage collected. The same applies formovie1
.From Creating visual Flex components in ActionScript :
好吧,到目前为止,没有任何内容从内存中删除,这实际上取决于 movie1 的引用方式。假设稍后在应用程序中您想要再次添加 movie1,您应该发现 movie1 不仅还在这里,而且还包含 movie2 和 movie1。电影3.
Well, nothing is removed from memory so far , it really depends on how movie1 is referenced. Let's say that later in the application you want to add movie1 again, you should find that movie1 is not only still here but it also contains movie2 & movie3.
当然,它会删除所有 3。
子电影 1 有两个子电影,电影 2 + 3。
如果他因某种个体死亡而死亡,孩子们也可能会死亡。
也许我错了,但你也可以尝试:
Ofcourse it removes all of the 3.
Child movie 1 has two children, movie2 + 3.
If he dies because of some Instance decease the children will possibily die too.
Maybe I'm wrong but you can also try: