Reputation: 4151
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
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