Load stream into memory outside the program scoop

时间:2018-01-23 19:17:37

标签: c++ windows memory

I am debugging a program that depends on large file ~1GB. I am currently stuck in low performance PC without SSD. Each time I run the program after some edit. This 1GB has be loaded in memory which takes some time.

considering I need this 1GB file from the beginning and there is no way to load just what I need from it.

Is it possible in some way (does not have to be standard and portable) to load it just once in some place in the memory that is not destructed after exiting the program and then use it from the same place in memory each time (kind of pointer to memory chunk on the OS level) ?

I am using MSVC 2017 & Windows 10.

1 个答案:

答案 0 :(得分:1)

Yes, try setting up a RAMDisk and storing this file in the RAMDisk. It will persist until you shut down your machine or delete it.

This will effectively allow your system to read from/write to this 1GB file as if it was stored on RAM - which is what you want. But it will only require a single load and a single unload.

A normal 7200RPM hard drive - what you're probably seeing by loading from HDD -> RAM upon each execution

7200RPM

A very usual SSD. As you can see, speeds are increased approximately fourfold in this benchmark.

SSD

Using a RAMDisk, in this case set up using the AMD Radeon RAMDisk software

RAMDISK

In other words, this isn't a programming solution really - it's just a workaround for your machine not having an SSD to store this large file on for read/write purposes. Your code can probably stay the same, it will just read in the file from a RAMDISK that you'll have to set up.

Hope this helps!