使用文件系统来增强内存
我应该先说我正在开发袖珍 PC 应用程序,数据文件存储在 SD 卡上。
我有一个应用程序必须创建一个大小为 x 的数组。 malloc 每次都失败。
我在 4 GB 卡上有一个 1 GB 文件。
我有 64 兆板载内存 (ram/data/application/os)
我无法处理数据,因为我需要的数组太大。
访问 SD 卡几乎与 RAM 一样快。
我正在使用 C++ (mfc)
访问我要用作数组的文件的最佳方式是什么?
或者会有不同的方法来做到这一点?
I should preface this by saying I'm working on a pocket PC app and the data files live on sd cards.
I have an app that has to create an array of size x.
malloc is failing every time.
I've got a 1 gig file on a 4 gig card.
I've got 64 megs of onboard memory (ram/data/application/os)
I can't process the data because the array I need is too big.
Accessing an sd card is almost as fast as ram.
I'm working in C++ (mfc)
what's the best way to access the file I'm going to use as an array?
Or would there be a different way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该创建一个对于数组来说足够大的文件,并进行适当的填充(根据 GetSystemInfo),并使用 CreateFileMapping/MapViewOfFile 映射该文件。
至少,这将是我的第一次尝试 - CE 上映射文件的大小可能会受到限制。
You should create a file large enough for the array, suitably padded (according to GetSystemInfo), and the map the file with CreateFileMapping/MapViewOfFile.
Atleast, that would be my first try - there might be restrictions on how large a mapped file can be on CE.
您需要创建一个包含 n 条记录的窗口(适合内存)并移动该窗口,以便将您正在处理的记录保留在其中。 我对 mfc 的了解不够熟练,无法为您提供代码示例,但这并不那么困难。
在 C# 中,我会编写一个自定义 IEnumerable
You'd need to create a window of n records (that will fit in memory) and move that window so as to keep the record(s) you're doing work on in it. I'm not fluent enough in mfc to give you a code sample, but it wouldn't be all that hard.
In c# i'd write a custom IEnumerable<T>