Kosmo零
Kosmo零

Reputation: 4151

Is there anyway to force program to use page file virtual memory when run out of RAM in .net?

struct SomeStruct
{
   //some fields, store ~3kb
}

List<SomeStruct> lst = new List<SomeStruct>();

for (int i = 0; i < int.MaxValue; i++)
   lst.Add(new SomeStruct(/*...*/)); //somewhere we get OutOfMemory exception

So... I want it to use virtual memory and continue working, instead of exception

Upvotes: 2

Views: 1645

Answers (1)

Kiwi
Kiwi

Reputation: 136

I'm pretty sure you can't do that. The idea behind virtual memory is that programs can't tell the difference. If you are getting an OutOfMemory exception, it means the OS has told you "you can't get anymore", including virtual memory.

If anything, you would need to fiddle with settings in the OS and how it handles virtual memory.

Upvotes: 3

Related Questions