Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Night Elf

Paging memory

This topic is 5405 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm programming a Windows application using C++. I must use a lot of memory, but I don't need to access it all at the same time. I would like to free memory allocated to currently unused objets for a while, but I don't want to delete the objets, I just want them to be paged to disk. Is there any way to force Windows to page-out some memory? Thanks for any help. Edit: To clarify a bit, I know that what I'm talking about is done automatically by the Windows memory manager. But what I want to do is to control when the paging-out occurs. [edited by - Night Elf on February 26, 2004 1:01:31 PM]

Share this post


Link to post
Share on other sites
Advertisement
Why do you want to avoid deletion? Do you use pointers that must be valid throughout the execution of the program?

just curious

/Q

Share this post


Link to post
Share on other sites
quote:
Original post by mattnewport
What makes you think you''d do a better job of deciding when to page stuff out than the OS?


Indeed, if the pages stop getting used, they''ll be swapped out pretty damn fast (tm).

If you were desperate, you could create a memory map with an unnamed file and forcibly sync said file to disk... although this wouldn''t swap out the page, it''d go ahead and write the pages to disk, thus removing the overhead required for a swap in/out.

-Mike

Share this post


Link to post
Share on other sites
The old way was using GlobalAlloc with a flag that prevents it for being swaped but it doesn''t work anymore, this days VirtualLock is your friend.
But as other''s already said, you''re going into a hell of a problems there, in any case is funny and interesting to poke around it.

-Mat

Share this post


Link to post
Share on other sites
You might try using CreateFileMapping with INVALID_HANDLE_VALUE. "In this case, CreateFileMapping creates a file-mapping object of the specified size backed by the operating-system paging file rather than by a named file in the file system." Don''t forget to pass the returned file mapping handle to MapViewOfFile.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!