views:

162

answers:

2

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?

+2  A: 

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.

Martin v. Löwis
A: 

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>

Kris