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

The Archive Base Latest Questions

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

Can we have any size of Java object without any fear of exception? I

  • 0

Can we have any size of Java object without any fear of exception? I am going to use an object of a class that consists of an ArrayList of thousands of other objects that contains couples of HashMaps and ArrayLists and many other non primitive type.

Thank you

  • 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:20:39+00:00Added an answer on May 16, 2026 at 12:20 pm

    Java Heap is limit for size of objects those you can have in system. If your object’s size is beyond heap then Out Of Memory error would be generated.

    In your case your total object’s size (Object’s in ArrayList + other objects in your system) matters more, As your ArrayList would be just referencing these Object’s.

    Here are VM options you can use to set Heap Size as per your requirement (from the java documentation):

    -Xmsn

    Specify the initial size, in bytes, of
    the memory allocation pool. This value
    must be a multiple of 1024 greater
    than 1MB. Append the letter k or K to
    indicate kilobytes, or m or M to
    indicate megabytes. The default value
    is 2MB. Examples:

           -Xms6291456
           -Xms6144k
           -Xms6m
    

    -Xmxn

    Specify the maximum size, in bytes, of
    the memory allocation pool. This value
    must a multiple of 1024 greater than
    2MB. Append the letter k or K to
    indicate kilobytes, or m or M to
    indicate megabytes. The default value
    is 64MB. Examples:

           -Xmx83886080
           -Xmx81920k
           -Xmx80m
    

    Check Heap info from VM Spec

    3.5.3 Heap

    The Java virtual machine has a heap that is shared among all Java virtual machine >threads. The heap is the runtime data area from which memory for all class instances and >arrays is allocated.
    The heap is created on virtual machine start-up. Heap storage for objects is reclaimed by >an automatic storage management system (known as a garbage collector); objects are never >explicitly deallocated. The Java virtual machine assumes no particular type of automatic >storage management system, and the storage management technique may be chosen according >to the implementor’s system requirements. The heap may be of a fixed size or may be >expanded as required by the computation and may be contracted if a larger heap becomes >unnecessary. The memory for the heap does not need to be contiguous.

    A Java virtual machine implementation may provide the programmer or the user control over >the initial size of the heap, as well as, if the heap can be dynamically expanded or >contracted, control over the maximum and minimum heap size.5

    The following exceptional condition is associated with the heap:

    If a computation requires more heap than can be made available by the automatic storage management system, the Java virtual machine throws an OutOfMemoryError.

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

Sidebar

Related Questions

Can any one tell me an opensource js library that can have a real-time
Does anyone have any recommendations for tools that you can add to Eclipse, Netbeans
Im learning Java and having a problem with ArrayList. Firstly I have a class
I use Java 6 Collecetions API. I need a collection that should have only
I have a Jquery Mobile collapsible set , which can have any number of
Can I have any way to know which is the depth of a child
Anyone have any ideas what I can do? Please reserve commenting about using 1.1
Does anyone have any idea on how can you create a product filtering query
Does anyone have any idea if you can find source JARs on Maven repositories?
Does anyone have any suggestions about where I can find a C# implementation for

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.