Cache files

Started by
3 comments, last by jtech 22 years, 1 month ago
Why do some programs explicitly store large amounts of data in temporary cache files (e.g. c:/windows/temp) ? Isn''t this what virtual memory is used for? Doesn''t Windows do all of this for you? Why are these programs, like Photoshop, doing it themselves? I assume they are, as I have never seen any of my programs dump data into the temp folder without my knowledge.
Advertisement
Sometimes its nice to have a backup copy of your work on disk in case of a crash. I know most word processing programs save a temp file somwhere for this reason.

Other reasons may be the programmers have developed a custom paging scheme for their app that works better for their needs than the default OS one.
I was just wondering if doing my own disk caching would improve performance
and minimize hard drive thrashing. If say, I wanted to dynamically allocate
a large chunk of memory with the new operator. Would I really want to write
it to disk, or just keep it in memory.
Doing your own caching can, under certain circumstances, dramatically increase performance. Especially under Win9x, where memory management is unbelievably bad. Eg. if you want to swap out a continous region of memory, and swap it in later, it is faster to do a single fwrite/fread on the buffer, than letting Windows handle it through the general purpose virtual memory swapper. On Win2k, it''s somewhat different, since memory management is alot better. Although, when done right, it can still improve performance. Be careful though, or Windows will actually cache your swapfile in system memory...
quote:
Be careful though, or Windows will actually cache your swapfile in system memory...


That would defeat everything if Windows knew about my cache file. Does
Windows leave freads/fwrites alone? What about CreateFileMapping?
I wonder if there are some tricks with CreateFileMapping that tells the
Windows swap file to leave it alone.

This topic is closed to new replies.

Advertisement