Skip to main content
gamedev.net
🔒 Locked

Virtual Memory in .NET?

Started by Brobanx Dec 30, 2002 at 3:44 AM 3 replies 750+ views
Original Post
Brobanx
Brobanx
I''m new to programming in the .NET framework, and I''m wondering if there''s any way I can get my program to use virtual memory rather than RAM. My search of the docs leads me to believe I''d have to call the Win32 Functions, but even then I''m not sure how I''d tell my C# code to use that memory.
thona
thona
I suggest you read up on whatVirtual Memory IS before trying to put your program there manually.

Or, in other words: LEAVE THIS TO THE OPERATING SYSTEM.


Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)
RegardsThomas TomiczekTHONA Consulting Ltd.(Microsoft MVP C#/.NET)
Wyrframe
Wyrframe
Exactly what you said, Thona.

Brobanx, virtual memory is where the OS temporarily pushes a bunch of RAM onto the hard drive, to be used later. Picture RAM as a desk. Lots of RAM means a bigger desk. But if you need more space to work on something in specific, you can just grab this stack of papers over here and drop them in a filing cabinet until you need it again.

Sorry if the example sounds condescending. But, picture it like this. The operating system is the guy at the desk who does all the work. You just dictate your orders through him, and sometimes he suddenly goes neon blue and screams out "GENERAL PROTECTION FAULT!".

Ahem.

The operating system will do all that on its own. Don''t worry about it. Now, if you want to force the OS to NEVER push your program into virtual memory, we''re talking about an entirely different color of horse. Turquoise, maybe. Or that neon blue again...
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.
CWizard
CWizard
On Windows (and most other OSes), everything (except some low-level stuff) is in virtual memory. What above posters refered to was the swap space. Virtual memory is an abstraction over physical memory, so that a virtual memory address (such as a pointer in your program) is not the real address of the data in your RAM chips. A unit call MMU ([Paged?] Memory Management Unit) does the translation between virtual and physical addresses through a translation table. This way, Windows give each process its own 4 GB virtual address space and change the MMU''s translation table between context switches.

I think you should goto MSDN an read up on Windows virtual memory model, and then read through the memory reference, which have functions that instructs Windwos to handle memory in various ways. I think you''ll find, though, that you don''t need to worry about this at all.


Brobanx
Brobanx
Silly me, I forgot that Windows puts things in virtual memory automatically.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.