Manual Memory Paging in the .Net Framework (Is it

2019-05-06 17:42发布

问题:

I have a major interest in writing a database management system. Having read a few pages about how SQL Server 2000 was implemented, I discovered that 4KB memory pages were used, each being a direct copy of a 4KB page on the hard disk. These pages were loaded into RAM as needed, and then lazily wrote back to disk when they fell idle (oversimplification).

Being in the planning stage of my project, I am wondering if this level of control is possible in code running on the CLR. I realize that C, C++, or D is probably a better fit for this task, but I would like to prove that to myself first. Part of the motivation behind this is that I would eventually like to actually override the CLR Garbage Collector with my own, using my database as the heap, at least for relatively stale objects.

Is it possible to directly control memory from the CLR? If so, how would I do this?

Assume for now that my data is a bunch of 256 byte wide structs/classes, stored in a flat table on disk, and I'm using 64KB pages.

回答1:

Sort of. You can use memory mapped files in .NET so that writing to "memory" is really writing to disk.