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.

Memory usage increase with looped LiveLink for MATLAB

Please login with a confirmed email address before reporting spam

Question: How can I eliminate the LiveLink for MATLAB server from storing "things" in my computer memory when I run it?

Situation: I am working on simulating li-ion battery at different conditions using For-loop function in MATLAB. Since I am running many iterations, my computer slowly run out of memory before I can finish all the possible conditions. These different conditions need to be run in a single run for optimization purposes, thus the option of separating them into smaller chuck cannot apply here.

Why can't the LiveLink for MATLAB runs like the normal COMSOL software, where with each new run the memory usage is reset.

Thing I have tried: I have look through the User Guide for LiveLink for MATLAB and here are what I found: 1. We can remove all the model objects by using the following command: ModelUtil.clear 2. We can disable the model history by using: model.hist.disable Even after I tried these two commands, the memory usage for the LiveLink server still increase everytime I run the model. And the memory does not reset itself. I have to close the program and rerun it to reset the memory.

Please let me know if you have any suggestions.

Thank you!


3 Replies Last Post 18 giu 2019, 07:39 GMT-4
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 6 years ago 29 apr 2019, 03:38 GMT-4
Updated: 5 years ago 18 giu 2019, 07:45 GMT-4

Hi

This shouldn't happen, of course.

If you haven't done so already then upgrade to Comsol 5.4 update 3.

If that doesn't work for your model then consult this knowledge base entry: https://www.comsol.eu/support/knowledgebase/1264

-------------------
Lars Gregersen
Comsol Denmark
Hi This shouldn't happen, of course. If you haven't done so already then upgrade to Comsol 5.4 update 3. If that doesn't work for your model then consult this knowledge base entry:

Please login with a confirmed email address before reporting spam

Posted: 6 years ago 6 mag 2019, 14:20 GMT-4

Hi Lars Gregersen,

Thank you! the solution given in the knowledge base entry works!

Best, Yu Hui

Hi Lars Gregersen, Thank you! the solution given in the knowledge base entry works! Best, Yu Hui

Please login with a confirmed email address before reporting spam

Posted: 5 years ago 18 giu 2019, 07:39 GMT-4

Hi,

This was a well formulated forum post Yu Hui Lui, thank you for posting! I also stumbled into the exact same problem (Ubuntu 18.04.2 LTS, COMSOL 5.4). I am performing many simulations in a sequence via the MATLAB LiveLink module. In my case, the used RAM would "partly reset" (around 50% RAM reset) after each simulaton, but still COMSOL stored about half of the data from the previous simulation to the next. This caused the RAM usage to slowly accumulate until I hit the 16 GB limit on my computer, and then COMSOL switched to use the SWAP-memory of Linux. This continued until my SWAP-memory ran out, and finally everything crashed and was shut down.

Luckily for me, the solution in the knowledge base entry 1264 presented by Lars Gregersen worked for me! Now I can perform all of my simulations since the RAM usage resets after each simulation. I hope that this post can help more people solve their RAM issues when working with MATLAB LiveLink (this doesn't seem to happen in COMSOL client with GUI). It was definitely not obvious for me that my problem stems from a memory leakage bug in the Fortran Runtime Libraries.

Best regards Sephia

Hi, This was a well formulated forum post Yu Hui Lui, thank you for posting! I also stumbled into the exact same problem (Ubuntu 18.04.2 LTS, COMSOL 5.4). I am performing many simulations in a sequence via the MATLAB LiveLink module. In my case, the used RAM would "partly reset" (around 50% RAM reset) after each simulaton, but still COMSOL stored about half of the data from the previous simulation to the next. This caused the RAM usage to slowly accumulate until I hit the 16 GB limit on my computer, and then COMSOL switched to use the SWAP-memory of Linux. This continued until my SWAP-memory ran out, and finally everything crashed and was shut down. Luckily for me, the solution in the knowledge base entry 1264 presented by Lars Gregersen worked for me! Now I can perform all of my simulations since the RAM usage resets after each simulation. I hope that this post can help more people solve their RAM issues when working with MATLAB LiveLink (this doesn't seem to happen in COMSOL client with GUI). It was definitely not obvious for me that my problem stems from a memory leakage bug in the Fortran Runtime Libraries. Best regards Sephia

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.