Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Matlab memory usage

Please login with a confirmed email address before reporting spam

Hi everyone,

I have a simple question regarding the Comsol w/ Matlab interface. I have noticed that when I run long parametric sweeps, sometimes I will run out of memory. Since some of my models are fairly memory intensive, this part does not surprise me. However, when I run out of memory, I will clear the workspace using the "clear" command. When I do this, I then check the virtual memory being consumed by Matlab, and I have noticed repeatedly that it is still using nearly as much as before I cleared the workspace. Currently, my only solution is to shut down Matlab completely and restart. Only then will the virtual memory usage go down to a reasonable value.

Has anyone else experienced this problem? Are there any other options I could try so that I don't have to do a full shut-down. Are there any other variables or processes running in the background that I should be aware of? This may be more of a Matlab issue than Comsol, but I've only noticed it with Comsol since its calculations are so memory intensive.

Thanks,

Mike

3 Replies Last Post 16.12.2009, 14:15 GMT-5

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 04.12.2009, 07:24 GMT-5
I think it is more a Comsol thing than a Matlab thing - typically the only way I have found to get it to release the memory properly is to close both the applications. Not quite sure what causes the problem to happen though I'm afraid.
I think it is more a Comsol thing than a Matlab thing - typically the only way I have found to get it to release the memory properly is to close both the applications. Not quite sure what causes the problem to happen though I'm afraid.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16.12.2009, 14:06 GMT-5
I have run into this issue a few times. In one case a simple call to 'postscrossplot' would increase MATLAB's reported memory usage by 2+ GB each at each call and the memory would never release. One simple fix for my problem was to periodically reload/reread the MPH file. That would release the memory that MATLAB/COMSOL would not otherwise release, and leave all other variables in your workspace available.
I have run into this issue a few times. In one case a simple call to 'postscrossplot' would increase MATLAB's reported memory usage by 2+ GB each at each call and the memory would never release. One simple fix for my problem was to periodically reload/reread the MPH file. That would release the memory that MATLAB/COMSOL would not otherwise release, and leave all other variables in your workspace available.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16.12.2009, 14:15 GMT-5
A quick update. Another user privately e-mailed some helpful advice. Using the pack function helps to consolidate the workspace memory:

cwd = pwd;
cd(tempdir);
pack
cd(cwd)

I haven't recently had high memory usage problems, so I haven't been able to fully test the usefulness of this function. However, it does seem to make a difference even when I am only using a small amount of virtual memory. Hopefully this will help others with the same problem.

Mike
A quick update. Another user privately e-mailed some helpful advice. Using the pack function helps to consolidate the workspace memory: cwd = pwd; cd(tempdir); pack cd(cwd) I haven't recently had high memory usage problems, so I haven't been able to fully test the usefulness of this function. However, it does seem to make a difference even when I am only using a small amount of virtual memory. Hopefully this will help others with the same problem. Mike

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.