Izy-
Izy-

Reputation: 1163

Virtual Memory in Visual C++

I have a query regarding Virtual Memory. First of all, I would like to mention that I am new to the field of programming. I have read up on Visual Memory.

Now I have a program which opens softwares which require large amounts of memory (like for example a picture viewer). The concerned computer, however, cannot spare that much of memory for this . And this is all done with Visual C++. The picture viewer is currently running on physical memory.

But once this software is distributed, it will be used on computers which cant spare that much of physical memory. So my task is to research and find out how to switch this program from using physical memory to virtual memory. In the end I will probably be implementing this myself.

So my question is, how do I alter the code in such a way that I can prevent the application from using physical memory and instead, switch over to virtual memory?

I'm not asking for someone to provide me with a copy paste code ofcourse, but just a method to do so. Also, if someone could explain the logic behind it, I would appreciate it.

Loads of thanks in advance.

Upvotes: 0

Views: 375

Answers (2)

Ben Voigt
Ben Voigt

Reputation: 283624

You can't use virtual memory without using some physical memory. There's a reason for the name swapfile. The processor cannot directly operate on data in secondary storage, such as hard disks. It must first copy it into RAM.

Upvotes: 0

StilesCrisis
StilesCrisis

Reputation: 16290

The operating system is in charge of deciding what should be stored in RAM and what should be paged out to VM. Under certain abnormal circumstances, it can be useful to can provide advice to the OS from your app, but this is only recommended for experts. As a novice, your best bet is to trust that the OS will do the right thing.

Why do you think you need special behavior anyway? Pictures are generally small anyway. Unless your app is dealing with thousands and thousands, they will fit in RAM.

Upvotes: 1

Related Questions