Java garbage collector runs with priority 1, due to which it is not guaranteed that System.gc() will actually execute if called.
Is there any way to change its prio
Even if you upped the thread priority to 11 System.gc will not guarantee anything. All you can be sure of is that if Java needs to GC it will before it throws an out of memory exception.