MXCREATEDOUBLEMATRIX memory overflow error

3 ビュー (過去 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 Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by