Skip to main content
Inspiring
May 17, 2014
Answered

GC overhead limit exceeded

  • May 17, 2014
  • 3 replies
  • 4807 views

Hi All,

org.apache.poi java library helps to create an excel files as:

<cfset setFile = createObject("java","java.io.FileOutputStream") />

        <cfset xlsFile = setFile.init(filepath) />

        <cfset writeableWorkbook = createObject("java","org.apache.poi.xssf.usermodel.XSSFWorkbook") />

        <cfset cellStyleStatic = createObject("java","org.apache.poi.xssf.usermodel.XSSFCellStyle") />

        <cfset region = createObject("java","org.apache.poi.ss.util.CellRangeAddress") />

<!--- Insert cells and rows --->

        <cfset temp = writeableWorkbook.write(setFile)>

        <cfset temp = setFile.close()>

The process fail with out of memory error for 17,000 plus rows: GC overhead limit exceeded.

Anybody knows how to fix this issue?

Thanks!

    This topic has been closed for replies.
    Correct answer jfb00

    It works fine now. The key was in this line:

    <cfset writeableWorkbook = createObject("java","org.apache.poi.xssf.streaming.SXSSFWorkbook").init(1000) /> 

    I didn't have the 1000 buffer before. Thanks!

    3 replies

    BKBK
    Community Expert
    Community Expert
    May 20, 2014

    <cfset cellStyleStatic = createObject("java","org.apache.poi.xssf.usermodel.XSSFCellStyle") />
    <cfset region = createObject("java","org.apache.poi.ss.util.CellRangeAddress") />

    These objects are taking memory space, but it is unclear what they are there for. As they stand, they are redundant.

    Anit_Kumar
    Inspiring
    May 20, 2014

    They seems to me, Apache poi for excel. Though i am not sure and even unclear about their usage here.

    Regards,

    Anit Kumar

    BKBK
    Community Expert
    Community Expert
    May 17, 2014

    Shouldn't the 'write' line involve the file? What about replacing

    <cfset setFile = createObject("java","java.io.FileOutputStream") />

    <cfset xlsFile = setFile.init(filepath) />

    with

    <cfset xlsFileOut = createObject("java","java.io.FileOutputStream").init(filepath) />

        

    and

    <cfset temp = writeableWorkbook.write(setFile)>

    <cfset temp = setFile.close()>

    with

    <cfset temp = writeableWorkbook.write(xlsFileOut)>

    <cfset temp = xlsFileOut.close()>

    jfb00Author
    Inspiring
    May 19, 2014

    Thanks for your reply and help.

    I did the change BKBK.

    Carl : that helps, i can do more than 17K but no more than 40K. I am getting Error: Java heap space.

    Any ideas?

    Anit_Kumar
    Inspiring
    May 19, 2014

    Setting a high value for Xmx or permgen is probably not a good idea. You need to tune the values, not exactly, but appropriately. You may refer to http://www.adobe.com/devnet/coldfusion/articles/coldfusion_performance.html for performance tuning.

    You can use jmeter to test whether the Java heap space error is due to, heap memory or non-heap memory.

    For load testing, download jmeter from the link https://jmeter.apache.org/download_jmeter.cgi

    Here are the steps to be followed:-

    1. Test paln -> Right click --> Add - Thread group
    2. Right click on Thread group --> Add - Sampler- HTTP Request
    3. Right click HTTP Request --> Add- Listener - View Results in Table
    4. Click on HTTP REquest  and enter the server name like localhost or ip address, then port number of your site like 80
    5. Enter the path as : http://localhost:81/hello.cfm
    6. Click on Thread Group in left panel. Increase the number of threads as 40 or something like that. Enter the loop count like 5000 or so
    7. Now click on the green start icon at top and click on view results in table

    NOTE: click on apache-jmeter-2.10.zip under binaries

    If the non-heap memory is increasing then, the perm gen value needs to be recalculated. Whereas, if the heap memory is increasing then the Xmx needs to changed.

    Hope that helps

    Regards,

    Anit Kumar

    jfb00Author
    Inspiring
    May 17, 2014

    All,

    I increase the  from 512 to 2048. It process more records but still short memory if i included all records.

    Any ideas?

    Thanks

    Legend
    May 17, 2014

    in Server Settings > Java and JVM > JVM Arguments

    increase -XX:MaxPermSize=192m to say 512m. Restart CF to apply.

    HTH, Carl.