I have the following code:
for i=1:N,
some_mex_file();
end
My MEX file does the following:
- Declares an object, of a class I defined, that has 2 large memory blocks, i.e., 32x2048x2 of type double.
- Processes the data in this object.
- Destroys the object.
I am wondering if it takes more time when I call a MEX file in a loop that allocates large memory blocks for its object. I was thinking of migrating to C++ so that I can declare the object only once and just reset its memory space so that it can be used again and again without new declaration. Is this going to make a difference or going to be a worthless effort? In other words, does it take more time to allocate a memory in MEX file than to declare it once and reuse it?