iOS:大文件流式传输
我想从 iOS 设备的磁盘上连续传输游戏的大型数据文件。 问题是是否有人之前使用 System.IO.FileStream 流式传输过此类文件(20MB 块)。我没有 iOS 设备,请自行测试,我不希望下次再购买。
有两个问题:
- 文件是否在未完全加载的情况下进行流式传输(我期望流的行为,但我不确定 MonoTouch 的处理)以及流式传输时的内存使用情况如何?
- 加载过程的性能如何,尤其是同时加载不同文件时?
感谢您提供任何信息。
I want to stream a large data file for a game continuously from the disk of a iOS device.
The question is if anyone has streamed such files ( Blocks of 20MB ) before by using a System.IO.FileStream
. I have no iOS-device do test it myself and i not expect to get one in the next time.
There are 2 questions:
- Is the file streamed without loading it fully ( The behaviour which i expect from a stream but i'm unsure about the handling of MonoTouch ) and how is the memory usage while streaming it?
- How is the performance of the loading process, especially when loading different files at once?
Thank you for any information.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MonoTouch 基类库 (BCL) 来自 Mono,因此许多代码都是开源的。在
FileStream
你可以在github上看到代码。你是对的,它不会完全加载。您将控制正在阅读的内容。
上面的链接显示默认缓冲区大小设置为 8192 字节 (8k),但多个构造函数允许您使用不同的大小(如果您愿意)。
但该缓冲区是一个内部缓冲区。当您调用诸如
读取
,这样您就可以再次控制正在使用的内存量。这很难预测,并且很大程度上取决于您的应用程序(例如文件数量、所需的总内存......)。您可以使用
FileStream
异步方法,例如BeginRead
,以便在需要时获得更好的性能。MonoTouch base class libraries (BCL) comes from Mono so a lot of the code is available as open source. In the case of
FileStream
you can see the code on github.You're right, it won't be fully loaded. You'll control what's being read.
The above link shows that the default buffer size is set to 8192 bytes (8k) but that several constructors allows you to use a different size (if you wish so).
But that buffer is an internal buffer. You'll provide your own buffer when you call methods like
Read
so you will be, again, in control of how much memory is being used.That's difficult to predict and will largely depend on your application (e.g. number of files, total memory required...). You can use
FileStream
asynchronous methods, likeBeginRead
, to get better performance if required.