I'm running a mex function that calls for c code (compiled in the same file as the mex function itself).when a simulation is done, it seems matlab doesn't release the memory it uses since i see a growing amount of memory being used by matlab (via task manager).

it reaches the limit of my computer and then either crashes or simply continues to run forever.