I have created an ArrayList (Java) of my custom class objects with a size around 3000. But when I run my code it gets the error "Heap space error".
I want to keep thousands of objects in an ArrayList at runtime without getting out of heap space.
How can the heap space error be avoided?