Mex: out of memory mxCreateNumericArray

2 views (last 30 days)
Hello,
i m getting an error "out of memory" when i m declaring an large array. but when i m declaring an small array it works. Unfortunately i m beginner in mex. Can someone tell pls how i can solve this problem? Many many thanks!
// works
int dim[3] = {400,3,1000};
plhs[0] = mxCreateNumericArray(3, dim, mxDOUBLE_CLASS, mxREAL);
// doesnt work
int dim[3] = {4000,3,10000};
plhs[0] = mxCreateNumericArray(3, dim, mxDOUBLE_CLASS, mxREAL);

Accepted Answer

Friedrich
Friedrich on 22 Apr 2013
Hi,
that works fine for me. I assume you use a 32bit MATLAB? The variable you create needs 960mb of memory in one piece which is most likely not available for you.
You can use the memory command (Windows only!) to see what the biggest matrix is you can allocate.
Small advice: Don't use an int for the dimensions. Use mwSize. This is a bittedness independent type.

More Answers (0)

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!