Re: How to send or copy malloc() memory to heard disk



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
.



Relevant Pages

  • Re: teaching a child - console or GUI
    ... >> Are these objects very complex, or are they really a bunch of pointers ... >> One can hold a lot of those on disk ... ... Sure they do - however since memory is finite ... lists of pointers on disk, extract files of frequent search fields in ...
    (comp.lang.pascal.delphi.misc)
  • Re: Blue Screen of death
    ... I do have a memory checking program that I have not tried recently. ... It can be noted; that about 6 months ago, I added 2 Gig of ram; that I put in with what I had. ... For graphics testing, http://majorgeeks.com/3Dmark_d99.html has a copy ... You can test disk drives. ...
    (microsoft.public.windowsxp.hardware)
  • Re: SCO OSR5.0.6 System Crashed during LoneTAR Verify
    ... RAM; scrambled bits point the CPU toward disaster and it ... available that can really stress memory, but the best ones need to run ... disk corruption can cause otherwise good code to be read ...
    (comp.unix.sco.misc)
  • Re: Diagnosing extreme fps drop
    ... It's probably the game loading from disk all kinds of new textures on ... or competition for RAM by other memory hog apps like MS ... what the current and peak commit size shows in relation to the physical ...
    (alt.games.warcraft)
  • Re: High memory usage (*HELP*)
    ... Low on virtual memory does not necessarily mean anything with regard to disk ... If your system uses all the available RAM, ... acceptable for a server to put all of its available RAM to use. ...
    (microsoft.public.windows.server.sbs)