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

  • Home
  • SEARCH
  • 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 6943037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:06:12+00:00 2026-05-27T13:06:12+00:00

This is a question about garbage collection in java: if one allocates a large

  • 0

This is a question about garbage collection in java: if one allocates a large block of memory (using new int[BIG_NUMBER] or however), is there any guarantee that a garbage collector will collect the garbage before an OutOfMemoryError is thrown? Is this behaviour
of garbage collector a part of the Java spec by now?

I have learnt that a garbage collector itself might throw such exception in case it takes too long to collect the garbage, at least in the case of Sun Hotspot Java Virtual Machine

«The parallel / concurrent collector will throw an OutOfMemoryError if too much time is being spent in garbage collection: if more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered, an OutOfMemoryError will be thrown. This feature is designed to prevent applications from running for an extended period of time while making little or no progress because the heap is too small. If necessary, this feature can be disabled by adding the option -XX:-UseGCOverheadLimit to the command line. »

but this may be disabled, according to the citation, by adding an option to the command
line.

  • 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-27T13:06:13+00:00Added an answer on May 27, 2026 at 1:06 pm

    AFAIK, It has always been part of the Spec.

    The early OutOfMemoryError if the VM is very low on memory is a Java 6 feature and was introduced to stop the VM when it becomes unusable but not quite dead.

    I wouldn’t turn this feature off, you are far better off engineering your system so you never get close to 98% memory usage. I would suggest 30% is a more comfortable level to run at.

    From the Javadoc for Java 1.4.2 (introduced in 2002) http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/OutOfMemoryError.html

    Thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector.

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

Sidebar

Related Questions

I asked a question about Garbage Collection in Java in this topic . But
I think this question is really about my understanding of Garbage collection and variable
I have seen this question about deploying to WebSphere using the WAS ant tasks.
I have a question about the behaviour of Timer class in Java. This is
I have a question about how garbage collection might be handled in a linq
This question is about a Java JTree or a Window .Net Tree (Winforms) or
I have simple question about .net garbage collection. In the following code I create
In this popular question about why substring takes O(n) in C# , one of
Right now I'm reading this article regarding Java Garbage Collection: http://www.javaworld.com/javaworld/jw-08-1996/jw-08-gc.html ? Here is
This question about Timers for windows services got me thinking: Say I have (and

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.