comanighttrain

Is it possible to allocate 2Gb of memory using Virtual Alloc or CreateFileMapping (for shared mem)

I might be wrong but 2Gb would be 2 * 1024 * 1024 * 1024

Thanks

Dave



Re: Visual C++ General Memory allocation problem

crescens2k

Have you tried doing it If it succeeds then you can, if it fails then you can't.

But unless you are on a PAE system or x64 system I doubt you will be able to allocate 2GB of virtual memory because that is the entire available virtual address range for the process since half of it is for kernel use, and this would mean nothing else could get memory locations, (unless you are using the 3GB switch, but even with this I think it will be hard since it needs to get 2GB of contiguous virtual address space.)

CreateFileMapping is different though, since that is mapping a file to memory. You can do it but the way you do it will be tricky since, as above, you can't map the entire thing at once. You have to use CreateFileMapping and then MapViewOfFile to map small bits of the file that you want to work with.


But yes, 2GB is 2 * 1024 * 1024 * 1024 or 2,147,483,648.





Re: Visual C++ General Memory allocation problem

Sarath.

See sample code from MSDN on dealing with large sized shared memories






Re: Visual C++ General Memory allocation problem

comanighttrain

Thanks, that fixed my problemSmile

Dave