简体   繁体   中英

IBM java Heap memory issue in AIX server

I facing some heap memory issues in AIX server IBM java.

Firstly explaining the issue, below is the method in java which is invoked by C# code and Java code return the array list. Ie report object run method gives the array list. Then c# code will write that, array list into an file. This is the existing framework.

public List runReport( Integer ifeId, List params ) throws ReferenceCoreException
    {
        ReportInterface report=new ReportInterface();
        // sanity check
            // run the report
            // MED: need a way of getting this session's data source
            return report.run( HibernateSession.getDataSource(), ifeObj, params);
        }
        catch ( Exception e )
        {
            throw new ReferenceCoreException( e );
        }
}

Whenever we takes heap dump it is showing memory is fully occupied. Ie Xmx is 8 GB and heap dump also says 7.9 GB is full.

My question here is: Once the array list is returned it should ideally clear by GC. If not can I add finally block and make the report object to null like below?

public List runReport( Integer ifeId, List params ) throws ReferenceCoreException
    {
        ReportInterface report=new ReportInterface();
        // sanity check
            // run the report
            // MED: need a way of getting this session's data source
            return report.run( HibernateSession.getDataSource(), ifeObj, params 
              );
        }
        catch ( Exception e )
        {
            throw new ReferenceCoreException( e );
        }
    Finallay
       {
        report=null;
      }
  }

I feel if we make the report object to null then the connection between report object and array list returned by run method should be disconnected and GC can reclaim the array list heap memory. Is it correct? Please correct me if my understanding is wrong here.

Also suggest if we have any other approach to clear the array list once the report.run methods return the array list to C#?

Also why AIX server IBM Java is not throwing out of memory error, Java process is simply hanging?

report is a method local variable that becomes GC-eligible as soon as the method is left.

Explicitly setting null does the same of what is happening implicitly when the method returns.

This question might be helpful as well

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM