Forum Discussion
FICO
2 years agoCommunity Manager
Xpress Optimizer Memory Issue and Configuration
Hi,
We are using FICO Xpress optimizer version 8.12.3 in dot net C#. So we are using the BCL library along with the optimizer library.
We are containerizing the dot net service in a Linux container. While doing this we are putting the Xpress Linux Installation binaries in the container.
We have been seeing some unexplained memory issues where the application goes out of memory in the container. We cannot reproduce the same when running locally on a Windows machine.
In our application, we are solving multiple models iteratively.
I would greatly appreciate it if someone could help me with this. I have the following questions.
- What is the recommended way to create and destroy the solver and model objects in each iteration (C# BCL)?
- Are there any known memory issues in version 8.12.3 that can be fixed using the latest version?
- How can I find a recommended way to use Xpress on a Linux container along with dot net?
- Are there any recommended GC settings?
Thank you,
Shamsher
3 Replies
- FICOCommunity Manager
In order to correctly handle memory in C# BCL, make sure you Dispose() as soon as possible of any BCL objects that implement the IDisposable interface. For example, wrap them in a "using" block.
You may also want to use the XPRBexprContext class to make sure you get rid of XPRBexpr instances, which may otherwise a bit hard to assert.
In general, no special code should be required when running on Linux.
You may also want to switch to a more recent version of Xpress since some things about memory management improved in the last releases.
Finally, in version 9.4 a new C# API was introduced that is similar but more flexible than BCL. It also has a smaller memory footprint than BCL. You can find the details about this here.
- FICOCommunity Manager
Hi @Daniel Junglas ,
Thank you for the reply. I want to confirm if we are disposing of all Xpress entities correctly.
In our algorithm, we are solving multiple MIP models iteratively. For each step following is the way we use Xpress.
- We have an object XpressSolver which implements IDisposable.
- We initialize the OEM license in the constructor that does
- XPRB.init() and XPRS.License()
- Using XpressSolver we create an object called XpressModel like below
using (XPRBexprContext ctx = new XPRBexprContext()) { var bclProblem = new XPRBprob(problemName); var optimizerProblem = bclProblem.getXPRSprob(); return new XpressModel(problemName, bclProblem, optimizerProblem, new XpressParameterData(optimizerProblem), this.logger); }- Xpress model is also Disposable.
- We solve the model (creating variables, expressions, constraints etc.)
- Once the model is done we dispose bclProblem and optimizerProblem.
- Then we dispose the XpressSolver to release the license by calling
- XPRB.free()
Based on your answer It seems we are not using XPRBexprContext correctly. I believe we should create that object and keep it in the model and dispose of it when the model is done.
Please let me know if that understanding is correct. Also, do we need to dispose of any other Xpress objects like variables or constraints, etc.?
Best,
Shamsher
- FICOCommunity Manager
Yes, your understanding is correct: The lifetime of XPRSexprContext should be the same as XPRBprob.
There is no need to dispose of XPRBvar or XPRBctr, these are cleanup up automatically (in fact, they don't inherit from IDisposable, so you cannot even call Dispose() on them). The only other things that requires disposal is XPRBbasis in case you use that.

