Prevent an object from being paged out (VirtualLoc

2020-04-07 02:36发布

How would one go about keep an object in memory such that it won't be paged out by the OS in .Net?

i.e. Something similar to VirtualLock, but operating on an object, such that if compacting occurs and the object is moved it still would not be paged out, etc.. (I suppose one could pin the object's, determine what pages it belongs to, and then VirtualLock those pages, but that seems non-desirable for many reasons.)

If possible, could you point me to a reference or working sample? (C# ideally)

2条回答
做自己的国王
2楼-- · 2020-04-07 03:08

Have you looked at this one http://www.codeplex.com/NonPagedCLRHost ?

查看更多
够拽才男人
3楼-- · 2020-04-07 03:31

If you want deterministic response times you should use a real time OS that operates with the limits you specify, not Windows.

By definition, if they are infrequently used, the are high on the list of candidates to be paged out.

Here is a horrible solution: Create a thread (or an asynchronous timer) that once ever INTERVAL ms touches your object then goes back to sleep. Tune INTERVAL until you get the desired behaviour.

查看更多
登录 后发表回答