Enable java-main app to run out of memory repeatedly

[#51561265]
Merge 51561265- to master

[#51561265]