Flash视频播放器内存问题(Flash Video player memory issue)
我用播放列表制作了一个视频播放器。 大约45分钟后声音停止! 视频继续播放。 我播放短片(每个约3到4分钟)。
播放器基于2帧:
第1帧使用文件名定义变量VidReference:
VidReference = trackToPlay;
第2帧播放视频:
var nc:NetConnection = new NetConnection(); nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); nc.connect(null); var ns:NetStream = new NetStream(nc); ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); const buffer_time:Number = 2; ns.bufferTime = buffer_time; ns.client = this; ns.play(VidReference); var vid:Video = new Video(); vid.attachNetStream(ns); addChild(vid); vid_frame.addChild(vid);
一旦视频完成播放,它将进入第1帧(将新值放入VidReference变量)并返回第2帧以播放新视频。 我是否应该在每次加载新视频时删除视频对象? 我每次循环(第1帧>第2帧)并将每个视频添加到RAM中时,我是否实际声明了一个新的视频对象,最终压倒了Flash播放器?
我听说过垃圾收集,但我不知道如何删除视频对象,以便从内存中清除它(以及视频本身)。
当我检查System.totalMemory它每次加载新视频时都会加起来,我无法弄清楚如何从内存中删除旧视频。
I made a video player with a playlist. After around 45 min the sound stops! The video continues playing. I play short clips (about 3 to 4 min each).
The player is based on 2 frames:
Frame 1 defines the variable VidReference with the filename:
VidReference = trackToPlay;
Frame 2 plays the video:
var nc:NetConnection = new NetConnection(); nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); nc.connect(null); var ns:NetStream = new NetStream(nc); ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); const buffer_time:Number = 2; ns.bufferTime = buffer_time; ns.client = this; ns.play(VidReference); var vid:Video = new Video(); vid.attachNetStream(ns); addChild(vid); vid_frame.addChild(vid);
Once the video is done playing it goes to Frame 1 (to put the new value to the VidReference variable) and goes back to frame 2 to play the new video. Am I supposed to delete the video object each time it loads a new video? Am I actually declaring a new video object each time I'm looping (frame 1 > 2) and adding each video to the RAM, and in the end overwhelming the flash player?
I've heard about garbage collecting but I wouldn't know how to delete the video object so it is cleared (and the video itself too) from the memory.
When I check System.totalMemory it's adding up each time a new video is loaded, I can't figure out how to delete old videos from the memory.
原文:https://stackoverflow.com/questions/5670602
最满意答案
我相信你可以在块中启用缓存http://api.rubyonrails.org/classes/ActiveRecord/QueryCache/ClassMethods.html#method-i-cache
task your_rake_task: :environment do ActiveRecord::Base.connection.cache do # should cache queries inside the block end end
I believe you can enable the cache in a block http://api.rubyonrails.org/classes/ActiveRecord/QueryCache/ClassMethods.html#method-i-cache
task your_rake_task: :environment do ActiveRecord::Base.connection.cache do # should cache queries inside the block end end
相关问答
更多-
尝试使您的任务依赖于:环境Rails的任务: task :fill_products => :environment do # ... end 让我们看看会发生什么...... Try to make your task dependent on the :environment Rails' task: task :fill_products => :environment do # ... end and let's see what happens...
-
对于这个特定的任务,您只需要更改数据库连接,就像亚当指出的,你可以这样做: namespace :db do namespace :test do task :reset do ActiveRecord::Base.establish_connection('test') Rake::Task['db:drop'].invoke Rake::Task['db:create'].invoke Rake::Task['db:migrate'].i ...
-
为什么是rake db:migrate:reset没有列在rake -T中?(Why is rake db:migrate:reset not listed in rake -T?)[2022-11-29]
没有描述的任务将不会显示。 编辑:看起来DHH从Rails 3中删除了几个“减少噪音”的任务的描述。 rake db:setup有一个关于db:reset的注释。 http://github.com/rails/rails/commit/983815632cc1d316c7c803a47be28f1abe6698fb Tasks that don't have a description will not show up. EDIT: Looks like DHH removed the descripti ... -
显然系统无法找到sqlite3。 我必须提供安装路径。 以下是最后的片段 namespace :mockdb do sqlite_path = "/usr/bin/sqlite3" sql_file = "db/#{Rails.env}.sqlite3" desc "Back up the database" task :backup => :environment do puts "Backing up the database.." system "#{sqlite_pa ...
-
您可以使用以下命令将数据库重置回原始状态,然后再次运行迁移。 rake db:reset You can reset database back to the original state using the following command and run the migration again. rake db:reset
-
要访问rake任务中的导轨模型,您需要加载:环境。 task :my_task => [:environment] do User.new #... end 您不会在任务中调用调度程序,而是反过来调用。 您需要启动Rufus调度程序,然后从它们调用您的rake任务。 你需要先 # other require statements ... require 'rake' # ... scheduler = Rufus::Scheduler.start_new scheduler.cron "00 6 ...
-
Rails本地安装Rails应用程序rake db:迁移返回(Rails Locally Installing Rails Application rake db:migrate returns)[2023-01-22]
看起来你在迁移目录中有重复的迁移。 检查database_migrations / migrate下迁移的前缀,并确保没有复制多个版本或创建的迁移与存储库不同步。 It seems you have duplicate migrations in your migrate directory. Check the prefixes of the migrations under database_migrations/migrate and make sure you haven't copied mult ... -
这个监控配置对我有用 check process aws_sqs_consumer with pidfile /var/www/myproject/shared/tmp/pids/sqs_consumer.pid start program = "/bin/sh -c 'cd /var/www/myproject/current && BACKGROUND=y PIDFILE=/var/www/myproject/shared/tmp/pids/sqs_consumer.pid LOG_LEVEL=in ...
-
我相信你可以在块中启用缓存http://api.rubyonrails.org/classes/ActiveRecord/QueryCache/ClassMethods.html#method-i-cache task your_rake_task: :environment do ActiveRecord::Base.connection.cache do # should cache queries inside the block end end I believe you can ...
-
简短回答: db:schema:dump不是正确的选择,但你可以在Rakefile中添加几行代码来获得你想要的结果。 更长的答案: scuttlebutt是任务db:schema:dump实际上不应该转储除结构之外的任何东西。 (我知道,这是一个用词不当。)这与db:structure:dump类似,除了一个给你一个.rb文件,另一个给你一个.sql文件。 您可以通过将以下代码附加到Rakefile来创建自己的转储rake任务: 对于SQL 2008 task :mydump do ActiveReco ...