iOS:大文件流式传输

发布于 2024-12-29 03:19:26 字数 269 浏览 1 评论 0原文

我想从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

携余温的黄昏 2025-01-05 03:19:26

MonoTouch 基类库 (BCL) 来自 Mono,因此许多代码都是开源的。在 FileStream 你可以在github上看到代码。

文件是否在未完全加载的情况下进行流式传输(我期望流的行为,但我不确定 MonoTouch 的处理方式)

你是对的,它不会完全加载。您将控制正在阅读的内容。

流式传输时的内存使用情况如何?

上面的链接显示默认缓冲区大小设置为 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.

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 )

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).

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.

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 (e.g. number of files, total memory required...). You can use FileStream asynchronous methods, like BeginRead, to get better performance if required.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文