MXCREATEDOUBLEMATRIX memory overflow error

조회 수: 1 (최근 30일)
Lukas Bystricky
Lukas Bystricky 2020년 4월 3일
편집: James Tursa 2021년 12월 8일
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에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by