MXCREATEDOUBLEMATRIX memory overflow error

3 vues (au cours des 30 derniers jours)
Lukas Bystricky
Lukas Bystricky le 3 Avr 2020
Modifié(e) : James Tursa le 8 Déc 2021
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.

Réponses (1)

James Tursa
James Tursa le 8 Déc 2021
Modifié(e) : James Tursa le 8 Déc 2021
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)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by