2
  1. I want to determine the amount of free RAM at a particular instant so that I let the user know whether a particular operation is possible or not, depending upon whether necessary amount of RAM is available or not.

EDIT: I found this. But as Travis says, it is some what mix of paging & RAM. I would like to know only the free RAM memory.

  1. Secondly I would like to understand how to use paging in Windows if necessary amount of RAM is not available. Thank You.
Community
  • 1
  • 1
Cool_Coder
  • 4,888
  • 16
  • 57
  • 99
  • Google for 'Windows virtual memory management' – Martin James Aug 20 '13 at 12:23
  • 1
    There is not a portable way of doing this. You can use OS-specific APIs to get an idea of what's happening in a system but in general this is all purposefully transparent to applications. – mark Aug 20 '13 at 12:28
  • possible duplicate of [How to get available memory C++/g++?](http://stackoverflow.com/questions/2513505/how-to-get-available-memory-c-g) – Nicol Bolas Aug 20 '13 at 12:37
  • @MartinJames Thanks for your advice! I found a beautiful article here http://www.cprogramming.com/tutorial/virtual_memory_and_heaps.html – Cool_Coder Aug 20 '13 at 12:37
  • @NicolBolas what about the 2nd part of my question? – Cool_Coder Aug 20 '13 at 12:38
  • Thanks for the edit. I don't know enough about the subject to point you in the right direction, but the edit shows your effort and people have since answered your question. – Stephen D Aug 20 '13 at 12:53
  • For ms windows you should also look into address space, the /LARGEADDRESSAWARE linker setting and address space fragmentation if you are developing a 32 bit application. Remember that by default the address space of a 32 bit application is limited to 2GB regardless of the amount of ram you have in your PC. – drescherjm Aug 20 '13 at 13:07

1 Answers1

2

About paging: paging is performed automatically if enabled in Windows. No need to change your code to use it.

About free memory: Win32/MFC: How to find free memory (RAM) available?

You could also try to claim the memory. If successful, the operation can be performed. If you are going to use it anyway... This is not the nicest solution.

Community
  • 1
  • 1
Katjoek
  • 361
  • 1
  • 3
  • 11