Re: How to send or copy malloc() memory to heard disk
- From: mschaef@xxxxxxxxxxx (MSCHAEF.COM)
- Date: Fri, 23 Jun 2006 09:06:47 -0500
In article <1151040014.324926.253320@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
sandeep <sandeep.k@xxxxxxxxx> wrote:
I am working in VC++ programming. I am creating single linked
list,allocating buffer using malloc(1024) so now I want this copy this
memory to heard disk because some times both ram and swap memory is not
sufficient
Rob Thorpe's comment regarding pointers is the most salient: if you
have to write 'pointers' to disk, this can be tricky, particularly
if you need to deal with arbitrary circular structures, etc.
If you don't need to serialize pointers, it can be as simple as
fread/fwrite.
Now, judging from your comments, you're doing this because you need
the space. Exactly how much space do you need? If you can fit your
problem into a process address space (usually 2, sometimes 3GB on
32-bit machines), memory mapped files will work. That gives you
a structure that looks something like a huge array that happens
to be stored on disk. If you can't fit your problem into your
address space, you'll need to manually move data to and from
disk yourself.
One thing to keep in mind is that disk is slow. I just checked
the specifications on a Western Digigal 500GB drive and found it
to have an average seek time of 8.7ms and a latency of ~4ms. This
isn't much better than the disks folks were buying 10 years ago,
and is glacial in comparision to RAM or cache. (That said, bandwidth
and capacity have gone up signifiantly) Because of this, you need to
be careful when deciding how to use disk storage in your software.
You can pretty easily make your software so slow you don't care
how much capacity it has.
-Mike
--
http://www.mschaef.com
.
- References:
- How to send or copy malloc() memory to heard disk
- From: sandeep
- How to send or copy malloc() memory to heard disk
- Prev by Date: Re: Partial hash table?
- Next by Date: Re: Partial hash table?
- Previous by thread: Re: How to send or copy malloc() memory to heard disk
- Next by thread: Re: How to send or copy malloc() memory to heard disk
- Index(es):
Relevant Pages
|