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 7192511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:57:20+00:00 2026-05-28T19:57:20+00:00

I was reading Unveiling the java.lang.Out OfMemoryError and I was wondering if I’ve understood

  • 0

I was reading Unveiling the java.lang.Out OfMemoryError and I was wondering if I’ve understood it correctly. Is it true that if the Java VM throws a

java.lang.OutOfMemoryError: Requested array size exceeds VM limit

It means that the VM has rejected the creation of an array because it has exceeded a pre-defined limit (exceeded the likes of the VM), and not because I have run out of memory in the heap space?

Am I right to say that java.lang.OutOfMemoryError: Requested array size exceeds VM limit does not indicate a lack of memory?

Even if I have unlimited memory everywhere, the Java VM could still throw a java.lang.OutOfMemoryError: Requested array size exceeds VM limit if it doesn’t like my request to create an array of n size?

  • 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-28T19:57:21+00:00Added an answer on May 28, 2026 at 7:57 pm

    Quoting Troubleshooting Guide for Java SE 6 with HotSpot VM

    3.1.3 Detail Message: Requested array size exceeds VM limit (inline bold is mine):

    The detail message Requested array size exceeds VM limit indicates that the application (or APIs used by that application) attempted to allocate an array that is larger than the heap size. For example, if an application attempts to allocate an array of 512MB but the maximum heap size is 256MB then OutOfMemoryError will be thrown with the reason Requested array size exceeds VM limit. In most cases the problem is either a configuration issue (heap size too small), or a bug that results in an application attempting to create a huge array, for example, when the number of elements in the array are computed using an algorithm that computes an incorrect size.


    UPDATE: encouraged by the @Pacerier I did some quick testing. I wrote a sample program:

    public class VmLimitTest {
    
        public static final int SIZE = 2;
    
        public static void main(String[] args) throws InterruptedException {
            while(true) {
                byte[] a = new byte[SIZE * 1024 * 1024];
                TimeUnit.MILLISECONDS.sleep(10);
            }
        }
    }
    

    And run it with the following JVM options:

    -Xms192m -Xmx192m -XX:NewRatio=2 -XX:SurvivorRatio=6 -XX:+PrintGCDetails
    

    This is what they mean:

    • The whole heap is 192 MiB (-Xms192m -Xmx192m)
    • The young generation (eden + survivor) space is 64 MiB, old generation is 128 MiB (-XX:NewRatio=2)
    • Each survivor space (out of two) is 8 MiB, so 48 MiB is left for eden (1:6 ratio, -XX:SurvivorRatio=6)

    While testing I discovered the following:

    • If the newly created array can fit into eden (less than 48 MiB), the program runs fine
    • Surprisingly, when the array size exceeds eden size, but can fit into eden and one survivor space (between 48 and 56 MiB), JVM can allocate a single object on both eden and survivor (overlapping two areas). Neat!
    • Once the array size exceeds eden + single survivor (above 56 MiB) the newly created object is placed directly in old generation, bypassing eden and survivor spaces. This also means that suddenly full GC is performed all the time – very bad!
    • I can easily allocate 127 MiB of data but trying to allocate 129 MiB will throw OutOfMemoryError: Java heap space

    This is the bottom line – you cannot create an object with size larger than old generation. Trying to do so will result in OutOfMemoryError: Java heap space error. So when can we expect dreadful Requested array size exceeds VM limit?

    I tried running the same program with much larger objects. Hitting the array length limit I switched to long[] and could easily go up to 7 GiB. With 128 MiB of max heap declared the JVM was still throwing OutOfMemoryError: Java heap space (!) I managed to trigger OutOfMemoryError: Requested array size exceeds VM limit error trying to allocate 8 GiB in a single object. I tested this on a 32-bit Linux computer with 3 GiB of physical memory and 1 GiB of swap.

    That being said you should probably never hit this error. The documentation seems inaccurate/outdated, but it is true in one conclusion: this is probably a bug since creating such huge arrays is very uncommon.

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

Sidebar

Related Questions

Reading the documentation at http://jersey.java.net/nonav/documentation/latest/client-api.html#d4e704 makes me think that ClientFilter s are processed in
Reading through this question on multi-threaded javascript, I was wondering if there would be
Reading this post has left me wondering; are nightly builds ever better for a
Reading through the CKEditor documentation , I see that they have an option to
Reading this brief example of using memcached with PHP, I was wondering how memcached
Reading C++ Templates: The Complete Guide and it says Note that templates cannot be
Reading questions, comments and answers on SO, I hear all the time that MSVC
Reading up on content providers, I keep wondering why both the category and type
Reading Monitoring certain system calls done by a process in Windows , I'm wondering
Reading the Oxite source code, I have found that validators save bad property name

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.