Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1027431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:14:24+00:00 2026-05-16T12:14:24+00:00

The following code is throwing OutofMemoryError on Linux 3.5 enterprise box running jdk1.6.0_14 but

  • 0

The following code is throwing OutofMemoryError on Linux 3.5 enterprise box running jdk1.6.0_14 but running fine on JDK 1.6.0_20 I am clueless why its happening.

while (rs.next()) {
  for (TableMetaData tabMeta : metaList) {
rec.append(getFormattedString(rs, tabMeta));
  }
  rec.append(lf);
  recCount++;
  if (recCount % maxRecBeforWrite == 0) {
    bOutStream.write(rec.toString().getBytes());
    rec = null;
    rec = new StringBuilder();
  }
}
bOutStream.write(rec.toString().getBytes());

The getFormattedString() method goes here:

private String getFormattedString(ResultSet rs, TableMetaData tabMeta)
        throws SQLException, IOException {

    String colValue = null;
    // check if it is a CLOB column
    if (tabMeta.isCLOB()) {
        // Column is a CLOB, so fetch it and retrieve first clobLimit chars.
        colValue = String.format("%-" + clobLimit + "s", getCLOBString(rs,
                tabMeta));
    } else {
        colValue = String.format("%-" + tabMeta.getColumnSize() + "s", rs
                .getString(tabMeta.getColumnName()));
    }
    return colValue;
}

Below is the exception trace:

Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
        at java.util.Formatter$FormatSpecifier.justify(Formatter.java:2827)
        at java.util.Formatter$FormatSpecifier.print(Formatter.java:2821)
        at java.util.Formatter$FormatSpecifier.printString(Formatter.java:2794)
        at java.util.Formatter$FormatSpecifier.print(Formatter.java:2677)
        at java.util.Formatter.format(Formatter.java:2433)
        at java.util.Formatter.format(Formatter.java:2367)
        at java.lang.String.format(String.java:2769)
        at com.boa.cpal.cpal2repnet.main.CPALToReportNet.getFormattedString(Unknown Source)

I suspect that the use of String.format is the culprit, but not sure. How to overcome this issue?

Please note that this code has been written to query on the database that have huge tables to read the resultset and create extract files with specific formatting.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:14:24+00:00Added an answer on May 16, 2026 at 12:14 pm

    The exception you are getting refers to the GC overhead limit that is enabled by this HotSpot option:

    -XX:+UseGCOverheadLimit -Use a policy that limits the proportion of the VM’s time that is spent in GC before an OutOfMemory error is thrown. (Introduced in 6.)

    So, my best guess is that your application is simply running out of heap space. As @Andreas_D’s answer says, the default heap sizes were changed between jdk1.6.0_14 and JDK 1.6.0_20, and that could explain the different behaviour. Your options are:

    • Upgrade to the later JVM. (UPDATE – 2012/06 even JDK 1.6.0_20 is now very out of date. Later 1.6 and 1.7 releases have numerous security fixes.)

    • Explicitly set the heap dimensions -Xmx and -Xms options when launching the JVM. If you are already doing this (on the older JVM), increase the numbers so that the maximum heap size is larger.

    You could also adjust the GC overhead limit, but that’s probably a bad idea on a production server.

    If this particular problem only happens after your server has been running for some time, then maybe you’ve got memory leaks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code works great in IE, but not in FF or Safari. I
The following code doesn't compile with gcc, but does with Visual Studio: template <typename
The following code illustrates an object literal being assigned, but with no semicolon afterwards:
could someone please explain why the following code is throwing an error? // JavaScript
My app runs fine in the simulator, but when running on the device, it
Following code, when compiled and run with g++, prints '1' twice, whereas I expect
The following code should find the appropriate project tag and remove it from the
The following code is in the /Courses/Detail action: [AcceptVerbs(GET)] public ActionResult Detail(int id) {
The following code: template <typename S, typename T> struct foo { void bar(); };
The following code has a simple binding which binds the Text of the TextBlock

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.