Is there a way to allocate memory to a file instead of physical memory?
I mean, I want to write a function "file_new" which will mimic new operator and can used like this:
size_t size = 1<<35;
char * ptr = file_new(size, "c:\\myswap.tmp"); // Create a 1<<35 byte length file and map this file to virtual address
memset(ptr, 0, size); // Here solutions I have found, create a 1<<35 byte buffer in physical memory
The target system is supposed to be 64bit.
I have found solution which map memory to file (VirtualAlloc, CreateFileMapping, MapViewOfFile), but all finished to allocate memory in physical memory during the memset call.
Is there a solution to avoid to allocate this memory to physical memory?
Thank you for the answer, I tried the CreateFileMapping, but, during the memset operation, all the memory is copied in "RAM".
The only way I have found is to do manually a VirtualUnlock to free it. But, I can't call VirtualUnlock everytime I write in memory. And I may manipulate several big portions of memory >4GB at the same time.