Heap Overflow Example in Java

single custom object that will fill the heap with dozens of it.
  1. Create a reference to Custom object, that will stores object into the heap mem, and object reference of it into stack memory.
  2. As long as you continue keeping the reference to objects under program loop, heap usage will increase to a point unless program becomes heavy and unresponsive.
free memory in the heap after some execution time

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store