System running out of memory with repeated UQ analysis

I am addressing a problem in which I’m doing multiple bayesian inversions and reliability analysis after initializing a UQLab session. Since these repeated analysis are being carried out within a function, I’m assuming that once the control comes out of the function, the memory gets free.

My problem is that within one of such function runs, the system is getting out of memory if the number of MCS analysis is large despite clearing the Analysis object.

For example, if I have 800 MCS analysis with 3e5 samples each, then despite clearing the analysis object which results from uq_createAnalysis(MCSOpts) after extracting the probability of failure, the system goes out of memory after a few iterations. I also noticed that UQLab seems to keep a count of the number of simulations it has previously carried out, which can be seen from the Name variable inside the analysis object.

Is there anyway to save memory space when doing such multiple UQLab analysis? Do I need to run analysis with the -private flag to avoid memory issues?

It seems like -private flag seems to solve my problem and I’m no longer going out of memory.

Any ideas why?

1 Like

Dear @Shihab_Khan,
glad you found the solution, I was going to suggest it.

uq_createModel, uq_createInput and uq_createAnalysis store pointers to the created object in the UQLab session. This allows you to “bookkeep” your work and re-use different objects. You can see the list of avaialble model/input/analysis objects in memory by using the uq_listModels/uq_listInputs etc. commands. This is also what allows one to use the uq_getModel/Input/Analysis, or uq_selectModel/Input/Analysis tools.
The session is also saved by the uq_saveSession command and can be loaded at any time, so that you can store for the long term your work.

However, this has a drawback when repeated analysis are created in a row. If the analysis is large (e.g. a Bayesian inversion saving the sample history in high dimension), it can quickly fill the memory. When you use the “-private” flag, you are telling UQLab to stop saving the pointers to the objects created, which are therefore deleted as soon as your local variable referencing them is deleted.

I hope this is clear.

Best regards,


Thanks a lot Dr @ste for the explanation.