Dai
Dai

Reputation: 155270

Can I create a file in Windows that only exists in memory - and if so, how?

This question is not a duplicate of any of these existing questions:

To elaborate and to provide context:

Upvotes: 8

Views: 7201

Answers (1)

dxiv
dxiv

Reputation: 17648

CreateFileMapping with hFile = INVALID_HANDLE_VALUE "creates a file mapping object of a specified size that is backed by the system paging file instead of by a file in the file system".

From Raymond Chen's The source of much confusion: “backed by the system paging file”:

In other words, “backed by the system paging file” just means “handled like regular virtual memory.”

If the memory is freed before it ever gets paged out, then it will never get written to the system paging file.

Upvotes: 4

Related Questions