c++ - CreateFileMapping error code 8 -
createfilemapping error code 8.not enough storage available process command. im trying create file mapping 4 gb (0xffffffff) on 64bit win10 visual c++.
#define ubs_mem_size 0xffffffff handle hmapobject = createfilemapping(invalid_handle_value, nullptr, page_readwrite, hiword(ubs_mem_size), loword(ubs_mem_size), text("dllmemfilemap"));
how can solve "error 8" problem?
createfilemapping(..., hiword(ubs_mem_size), loword(ubs_mem_size), ...)
the lo/hiword macros generate word, 16-bit value. asking 0xffff0000ffff memory-mapped file. that's 282 terabytes. current x64 processors limited 48-bit vm-address, top out @ 8 terabytes. yes, error 8 (error_not_enough_memory) entirely expected.
don't use macros. can use large_integer alternative:
large_integer size; size.quadpart = ubs_mem_size; handle hmapobject = createfilemapping(..., size.highpart, size.lowpart, ...);
Comments
Post a Comment