View Single Post
Old 07-23-2007   #3 (permalink)
Richard Urban


 
 

Re: Setting virtual memory progrmmatically

Two things here.

1. When you change the size of the pagefile you have to reboot for the
change to take effect.

2. Why would you even want to do this. What you are doing is going to,
sooner or later, fragment the page file so it is no longer in one segment.

I would not allow a program that tries to do this anywhere near the
computers I maintain.

Photoshop does not do this. They create their own slush files on multiple
disks just for the use of their program. They do not screw with the pagefile
size. Your program should do the same.

--


Regards,

Richard Urban
Microsoft MVP Windows Shell/User
(For email, remove the obvious from my address)

Quote from George Ankner:
If you knew as much as you think you know,
You would realize that you don't know what you thought you knew!

"Setting virtual memory progrmmatically" <Setting virtual memory
progrmmatically@discussions.microsoft.com> wrote in message
news:F009A3C0-60FB-48C3-9742-B629BD17E772@microsoft.com...
> Hi
> We have a requirement to set the virtual memory programatically in Windows
> Vista. 
i.e. when we launch a application, set the virtual memory(say
> 2GB).
> 
When we quit the application reset it to the original virtual memory.
>
> I have used VirtualAllocEx().
> It works only when "Automatically manage paging file size for all
> drives" (This option is not there in Windows Xp) is selected in System
> Preference/Performance Options. It doesn't work when "Custom size" is
> selected in System Preference/
> Performance Options(works fine in Windows Xp).
> 
Please let me know how to handle this in Vista.
>
> See the code....
>
> dwProceeID = _getpid() ; 
 hProcess =
> OpenProcess( PROCESS_ALL_ACCESS, 0, dwProceeID); 

> lpVirtualMemoryAdd = VirtualAllocEx( hProcess, NULL,1024000000,
> MEM_COMMIT,PAGE_READWRITE);
> //getting NULL when "Custom size" is selected in Vista. 

> if( lpVirtualMemoryAdd) 
 { 

> VirtualQueryEx(hProcess, lpVirtualMemoryAdd, &memInfo,
> sizeof(MEMORY_BASIC_INFORMATION));
> VirtualFreeEx( hProcess, NULL, 0, MEM_RELEASE); 

> }
> BOOL bRet = CloseHandle(hProcess);
>
> Regards 
Sudesh


My System SpecsSystem Spec