[DUG] Saving aray

Jolyon Smith jsmith at deltics.co.nz
Tue Jul 8 08:49:30 NZST 2014


I would look at using a memory mapped file (MMF).  In this way, the memory
for your array is backed by storage in a designated file so there is no
need to explicitly, separately persist the contents of the memory to that
file when you are done.  You simply close the mapping.  Similarly there is
no need for separate, explicit subsequent loading of file contents into
memory - simply re-instate the mapping and contents of the file are mapped
directly into your address space.

The only thing to be wary of when using this technique is if you have
records in your data that contain references to other locations in the
memory, i.e. pointers, since these pointers are not certain to be
valid/correct when you re-map the file content.

But in the case of a simple array of integers this shouldn't be an issue.


On 7 July 2014 20:35, John Bird <johnkbird at paradise.net.nz> wrote:

>   I have a program that builds a very large array (over 1,500,000) of
> integers, and the calculation to fill the array takes quite a while –
> around 40-50 secs.   If there is a quick way to do it, I would save the
> array to disk if it was faster than recalculating it the next time.
>
> I am guessing that writing the elements to strings and using CSV etc would
> be quite slow, as it involves quite a lot of processing.   I will run a
> test to see.
>
> Is there any really fast way to save such an array to disk?   The numbers
> range between 0 and 256 if that helps.
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at listserver.123.net.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
> Subject: unsubscribe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20140708/e2f141f4/attachment.html 


More information about the Delphi mailing list