You can allocate more memory than you have physical RAM. The memory that is allocated is "virtual memory" and can in fact exist mostly on disk. This can then be very slow to use, of course, but depending on the algorithm (more specifically, the access pattern) it can work. Still, it's generally something you try to avoid, except perhaps for the case of a memory-mapped file.
Depending on what you are actually trying to do, it may be reasonable to use an OS function to determine how much actual RAM you have and then to request some large fraction of that. As long as you know that your process is the only memory hog on the system then it can work out okay.
To check for total/available memory on Windows: GlobalMemoryStatusEx function (sysinfoapi.h) - Win32 apps | Microsoft Docs
Code:
MEMORYSTATUSEX mem;
if ( GlobalMemoryStatusEx( &mem ) )
{
cout << "TotalPhys : " << setw(12) << mem.ullTotalPhys << '\n';
cout << "AvailPhys : " << setw(12) << mem.ullAvailPhys << '\n';
cout << "TotalVirtual: " << setw(12) << mem.ullTotalVirtual << '\n';
cout << "AvailVirtual: " << setw(12) << mem.ullAvailVirtual << '\n';
}
else
{
cerr << "GlobalMemoryStatusEx failed.\n";
}