简体   繁体   English

iOS:流式传输大文件

[英]iOS: Streaming of large file

I want to stream a large data file for a game continuously from the disk of a iOS device. 我想从iOS设备的磁盘连续流式传输游戏的大数据文件。 The question is if anyone has streamed such files ( Blocks of 20MB ) before by using a System.IO.FileStream . 问题是,是否有人在使用System.IO.FileStream之前已经流化了此类文件(20MB的块)。 I have no iOS-device do test it myself and i not expect to get one in the next time. 我没有自己做过iOS设备的测试,我不希望下次再得到它。

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? 是否在不完全加载文件的情况下流传输了文件(我期望从流中获取的行为,但是我不确定MonoTouch的处理方式),以及流传输时的内存使用情况如何?
  • How is the performance of the loading process, especially when loading different files at once? 加载过程的性能如何,尤其是一次加载不同的文件时?

Thank you for any information. 感谢您提供任何信息。

MonoTouch base class libraries (BCL) comes from Mono so a lot of the code is available as open source. MonoTouch基类库(BCL)来自Mono,因此很多代码都可以作为开放源代码使用。 In the case of FileStream you can see the code on github. 对于FileStream您可以在github上看到代码。

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 ) 是否在不完全加载文件的情况下流传输了文件(我期望从流中获取的行为,但是我不确定MonoTouch的处理方式)

You're right, it won't be fully loaded. 没错,它不会完全加载。 You'll control what's being read. 您将控制正在阅读的内容。

and how is the memory usage while streaming it? 以及流式传输时的内存使用情况如何?

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). 上面的链接显示默认缓冲区大小设置为8192字节(8k),但是几个构造函数允许您使用其他大小(如果需要)。

and how is the memory usage while streaming it? 以及流式传输时的内存使用情况如何?

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. 当调用诸如Read之类的方法时,您将提供自己的缓冲区,这样您将再次控制正在使用的内存量。

How is the performance of the loading process, especially when loading different files at once? 加载过程的性能如何,尤其是一次加载不同的文件时?

That's difficult to predict and will largely depend on your application (eg number of files, total memory required...). 这很难预测,并且在很大程度上取决于您的应用程序(例如,文件数量,所需的总内存...)。 You can use FileStream asynchronous methods, like BeginRead , to get better performance if required. 如果需要,可以使用FileStream异步方法(例如BeginRead )来获得更好的性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM