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
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
javadocumentation):Check Heap info from VM Spec