visual studio c++分配内存无法分配(matlab可以分配)解决思路

visual studio c++分配内存无法分配(matlab可以分配)
我有一个matlab程序,可以运行,但是速度慢,现在要改成c程序。
c程序中,我按照要处理的数据大小(大概需要占用2GB),使用calloc给数据分配内存的时候就出错,不能分配,但是maltab程序是可以运行的(数据大小一样)。
听说matlab分配内存的时候有用了什么扩展技术是吗?有什么办法可以让我的visual studio 的c程序也可以分配这么大的内存呢?

------解决方案--------------------
2G的堆空间,这个。。。这个。。
------解决方案--------------------
用malloc试一下.
calloc会进行初始化, malloc不会初始化, 因此可以超分
------解决方案--------------------
如果4G的内存的话,malloc了2G的堆空间以后,也干不了别的了吧。
------解决方案--------------------
大数据还是静态分配吧
------解决方案--------------------
用virtualqeury查询线性空间是否有这么大的连续空间吧
------解决方案--------------------
你的是64位系统么?
------解决方案--------------------
引用:
Quote: 引用:

你的是64位系统么?

8g内存,64位系统,4核cpu


应用程序要编成64位的.
------解决方案--------------------
引用:
Quote: 引用:

Quote: 引用:

Quote: 引用:

你的是64位系统么?

8g内存,64位系统,4核cpu


应用程序要编成64位的.

什么意思?我要是取一小块数据出来,用c程序处理是可以处理的,但是数据大了就内存分配不了了


64位CPU+OS上可以运行32位的应用程序,这样你的进程空间受限于2^32=4GB
------解决方案--------------------
CreateFileMapping
The CreateFileMapping function creates a named or unnamed file-mapping object for the specified file. 

HANDLE CreateFileMapping(
  HANDLE hFile,              // handle to file to map
  LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
                             // optional security attributes
  DWORD flProtect,           // protection for mapping object
  DWORD dwMaximumSizeHigh,   // high-order 32 bits of object size
  DWORD dwMaximumSizeLow,    // low-order 32 bits of object size
  LPCTSTR lpName             // name of file-mapping object
);
 
Parameters
hFile 
Handle to the file from which to create a mapping object. The file must be opened with an access mode compatible with the protection flags specified by the flProtect parameter. It is recommended, though not required, that files you intend to map be opened for exclusive access. 
If hFile is (HANDLE)0xFFFFFFFF, the calling process must also specify a mapping object size in the dwMaximumSizeHigh and dwMaximumSizeLow parameters. The function creates a file-mapping object of the specified size backed by the operating-system paging file rather than by a named file in the file system. The file-mapping object can be shared through duplication, through inheritance, or by name. 

lpFileMappingAttributes 
Pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by child processes. If lpFileMappingAttributes is NULL, the handle cannot be inherited. 
Windows NT: The lpSecurityDescriptor member of the structure specifies a security descriptor for the new file-mapping object. If lpFileMappingAttributes is NULL, the file-mapping object gets a default security descriptor. 

flProtect 
Specifies the protection desired for the file view, when the file is mapped. This parameter can be one of the following values: Value Description