| How can I allocate virtual memory? The following code
char* p = new char[1024 * 1024 * 512];
produces this error
terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc
Aborted
On Windows, if paging file permits, the allocation request would succeed and the kernel would return a pointer to a block of memory that is mapped in pagefile. However, you can do operations on the returned memory block just like you would physical memory.
I want to know is there any VirtualAlloc similar APIs on Linux. Thanks. |