I was looking into ArrayList.clear() & found that it doesn't free the memory instead made that list null. Why do you want to wait for GC to come & to free that memory (It could have done in clear method itself) when you can tell compiler manually that this particular ArrayList is no longer required.!!
Why do you want to give extra headache to GC Unnecessarily.
I know that System.gc() impacts the application performance since it runs garbage collection for the whole application.
Is there any way out to collect this particular ArrayList garbage instead of waiting GC to come to rescue in case of my server is having limited memory & list sizes are too too big.
Edit:- This problem arises because I have initialized a ArrayList(500000) & lets assume my object size is around 1000bytes due to some pre-initalized variables but due to some exception in forming first object itself I need to return from that function with freeing that memory which I have allocated to that ArrayList.I want my application to consume as low as memory it can. GC is the last resort for me.