FLVPlayback组件内存问题组件、内存、问题、FLVPlayback

2023-09-08 13:58:15 作者:纪念我们的曾经

我的网站是完全基于Flash的,它四处移动它给了我的视频,我已经转换为FLV文件块的3D模型。我使用FLVPlayback组件来控制我的程序里面的视频。在运行使用System.totalMemory内存检查我注意到,每当加载视频,它会吃了一个内存块,甚至当我删除它所有的事件监听器(它们都是弱引用),从删除组件其母公司,停止视频和空的组件实例,它仍然不会给内存了。

My website is entirely flash based, it moves around a 3D model which was given to me as chunks of video that I've converted to FLV files. I'm using the FLVPlayback component to control the video inside of my program. While running memory checks using System.totalMemory I've noticed that whenever a video is loaded, it will eat up a chunk of memory and even when I remove all the event listeners from it(they are all weakly referenced), remove the component from its parent, stop the video and null the component instance, it still will not give that memory back.

这一直困扰着我,因为我开始工作,因为大量的视频用户可以潜在地实例化和负载在这个项目上。目前,每个视频被装入时,它需要新的FLVPlayback实例,但我看过,也许去了解这个问题的最好方法是简单地拥有一个全球性的FLVPlayback实例,只是重新加载新的视频到旧的实例,这样,将只有在应用程序的内存中的一个FLVPlayback组件。

This has been bothering me since I started working on this project because of the huge amount of video a user can potentially instantiate and load. Currently every video is loaded into a new FLVPlayback instance whenever it is required, but I have read that perhaps the best way to go about this problem is to simply have a global FLVPlayback instance and just reload the new video into the old instance, that way there would only be one FLVPlayback component in the application's memory.

有没有其他人碰到这个问题呢?你有没有发现比使用刚重新使用全局实例为每一个新的视频更好的解决方案?

Has anyone else run into this problem as well? Have you found a better solution than using a global instance that you just re-use for every new video?

推荐答案

您不能帮助内存问题太多,直到Flash会析构函数和明确的对象删除,很遗憾。看到这个主题:

You can't help the memory problems much until Flash adds destructors and explicit object deletion, unfortunately. See this thread:

http://stackoverflow.com/questions/34/unloading-a-bytearray-in-actionscript-3

http://stackoverflow.com/questions/34/unloading-a-bytearray-in-actionscript-3

有一个限制多少内存的Flash小程序可以使用;气相色谱似乎火在达到该限制。我已经看到了我的记忆,容易使用的小程序尽可能〜200MB,只是因为它们运行几个小时就结束和GC不希望在踢。

There's a limit to how much memory Flash applets can use; the GC seems to fire upon reaching that limit. I've seen my memory-easy applets use as much as ~200MB, just because they run for hours on end and the GC doesn't want to kick in.

哦,我不认为使用单一实例是一个完美的解决方案,无论是。目前,我只写一个dispose()函数,我的自定义类,等待着有一天,当它可以变成一个适当的析构函数。

Oh, and I don't think using a single instance is an elegant solution, either. Currently I just write a dispose() function for my custom classes, waiting for some day when it can be turned into a proper destructor.