MXCREATEDOUBLEMATRIX memory overflow error

2 次查看(过去 30 天)
I have a mex file which calls MXCREATEDOUBLEMATRIX, for example
PLHS(1) = MXCREATEDOUBLEMATRIX(100,1,0)
At this line Matlab gives the error
Requested 4703255833574637668x429496729601 (17179869184.0GB) array exceeds maximum array size preference.
Obviously that's not what I actually want to request. What might be causing this?
For reference I am using Matlab 2018a on Ubuntu 16.04. The mex file is a Fortran file and I've linked it with the gfortran, iomp5, irc, svml, and imf libraries.

回答(1 个)

James Tursa
James Tursa 2021-12-8
编辑:James Tursa 2021-12-8
Rather later for an Answer, but here goes anyway:
You should never use literal integers for API calls, because you can't be sure the default literal integer size is the same as the integer size that the API routines expect. Always use typed variables that match the API doc exactly. E.g., here is the signaure from the doc:
mwPointer mxCreateDoubleMatrix(m, n, ComplexFlag)
mwSize m, n
integer*4 ComplexFlag
so the code sould be something like
mwSize m, n
integer*4 ComplexFlag
m = 100
n = 1
ComplexFlag = 0
plhs(1) = mxCreateDoubleMatrix(m,n,ComplexFlag)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by