Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  java.lang.OutOfMemoryError: Java heap space

    Posted 05/14/12 09:13 AM

    Originally posted by: Inspiredlallu


    Hello,

    In my Java Cplex application, I am creating a lot of Cplex objects using IloCplex. I use cplex.end() method to release the memory.

    Still my application is throwing heap space error.

    Any ideas on how to reslove this? I tried changing -Xms40m -Xmx512m values in the configuration file of eclipse. But it didnt help.

    Below is the error.

    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    at ilog.cplex.CpxLinearExpr.<init>(CpxLinearExpr.java:308)
    at ilog.cplex.CpxLinearNumExpr.<init>(CpxLinearNumExpr.java:41)
    at ilog.cplex.CpxQextractor.<init>(CpxQextractor.java:34)
    at ilog.cplex.CpxRange.<init>(CpxRange.java:1333)
    at ilog.cplex.IloCplexModeler.makeRange(IloCplexModeler.java:4032)
    at ilog.cplex.IloCplexModeler.range(IloCplexModeler.java:4421)
    at ilog.cplex.CpxRange.makeCopy(CpxRange.java:80)
    at InMemoryCplex.solveCplexDisjoint(InMemoryCplex.java:495)
    at InMemoryCplex.inmemoryDisjoint(InMemoryCplex.java:45)
    at InMemoryQuery.findDisjoint(InMemoryQuery.java:239)
    at UserInterface.actionPerformed(UserInterface.java:234)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    Thanks and Regards,
    Neha Bhatia
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: java.lang.OutOfMemoryError: Java heap space

    Posted 05/14/12 09:45 AM

    Originally posted by: SystemAdmin


    What do you mean by "eclipse configuration file"? Is this the file with options for eclipse? I think you need to specify -Xmx as virtual machine arguments in the run configuration for your project, not in the eclipse configuration itself. And 512 MB may not be enough.
    Is it expected that your program consumes a lot of memory or do you have the feeling that you are leaking memory?
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: java.lang.OutOfMemoryError: Java heap space

    Posted 05/14/12 10:11 AM

    Originally posted by: Inspiredlallu


    Hello,

    My program is creating thousands of in-memory objects. But I do not have to use them all simultaneously. Hence, I can destroy the object and create another one.

    Thus, my program is supposed to use a lot of memory. I thought the destroying each of the object using cplex.end() will solve the memory problem. But it is not doing so. Maybe there is a leak in memory, but I am not sure. So, am I destroying the object incorrectly?

    By the way, where is the run configuration of the project?

    Thanks and Regards,
    Neha Bhatia
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: java.lang.OutOfMemoryError: Java heap space

    Posted 05/14/12 01:44 PM

    Originally posted by: SystemAdmin


    cplex.end() is the correct way to release the resources that the native code allocated for a CPLEX object.

    The run configuration is used when you click on the "Run" button. It is where you specify command line arguments for your code and also arguments for the virtual machine that launches your code. You can find the list of run configurations via Run->Open Run Dialog.

    There are several tools that allow you to inspect the Java Heap at runtime to see what objects are allocated. I have not much experience with them so I cannot recommend one. But using such a tool might be helpful to make sure that only the expected objects are alive.

    BTW: Which version of CPLEX do you use? What are kind of problems do you solve (MIP, MIQP, MIQCP, LP, QCP, QCQP)? Does it help to set parameter IloCplex.IntParam.Threads to 1 for each call to IloCplex.solve()?
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: java.lang.OutOfMemoryError: Java heap space

    Posted 05/15/12 01:05 AM

    Originally posted by: Inspiredlallu


    Hello,

    I was able to create a dump file of the project when the error came using Memory Analyser of Eclipse. Attaching the figure of 'Biggest Top-Level Denominator Packages' if it helps.

    Anyway, I am using CPlex 11.0.0. And solving LP files. I am not sure of the usage of IloCplex.IntParam.Threads and hence don't know its effect of setting it to 1.

    Thanks and Regards,
    Neha Bhatia
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: java.lang.OutOfMemoryError: Java heap space

    Posted 05/15/12 07:26 AM

    Originally posted by: SystemAdmin


    I am not sure how to read that. What do the different columns mean? Does any of the columns count the number of live objects? What does it mean that '#Top Dominators" of class CplexI is 2629? Does it mean that there are this many live CplexI instances?
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: java.lang.OutOfMemoryError: Java heap space

    Posted 05/15/12 08:13 AM

    Originally posted by: Inspiredlallu


    Actually even I am not sure of how to read it. Even my analysis say the same as what you are saying.

    Attached is another of such result with different objects alive, so to say. And in this run it read more number of files and created more objects successfully than the previous run. So I am assuming the changes made by me in the program like range.clearExpr() and matrix.clear() helped clear more objects from memory and hence it solved a little more before giving the OOM error.
    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: java.lang.OutOfMemoryError: Java heap space

    Posted 05/16/12 04:51 AM

    Originally posted by: SystemAdmin


    I just checked here and could not find any memory leaks in the Java connector. Is it possible that you keep references to any Ilo* objects so that they cannot be garbage collected?
    In cases like this I sometimes use jmap and jhat to find out how many live instances of a certain class exist. To do that I would identify a point in my application at which I am sure no Ilo* objects should exist. At this point I would create a heap dump using jmap and inspect it using jhat. If there are unexpected instances of Ilo* objects then I can track them down using jhat as well and figure out what prevents them from being garbage collected.
    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: java.lang.OutOfMemoryError: Java heap space

    Posted 05/17/12 04:02 PM

    Originally posted by: GuangFeng


    How much physical memory do you have on your system? Are you using 32-bit or 64-bit JVM and CPLEX?

    How about increase the value of -Xmx even further and see if that helps? In case that doesn't help, would that makes the OOM happen earlier or later?
    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: java.lang.OutOfMemoryError: Java heap space

    Posted 05/22/12 11:53 AM

    Originally posted by: Inspiredlallu


    Hi,

    I use a 32-bit JVM and CPLEX. and have a RAM of 2GB.

    When I increase the value of -Xmx the OOM does not come for one type of input that I have been giving. It solves my problem to a certain extent but I dont see this as a solution as for different operations on my program which might deal with much larger files, again the OOM error comes. Hence, by just increasing the -Xmx parameters I cannot resolve this issue.

    @Daneil: I am trying to release all objects created by me but still not able to get to the root of the problem. I could not jhat and jmap. Could not find their implementation for windows eclipse.

    I tried swtiching on the 'show heap status' option in eclipse. Their in the heap dump the values shown to me at all times ranged between 48M - 87M. While the maximum it could go was till 151M. Even though the heap's usage range lied within 151M, the OOM error appeared and heap dump was created.

    Any clue on that?

    Thanks and Regards,
    Neha Bhatia
    #CPLEXOptimizers
    #DecisionOptimization