I am running a Bulk API in Java (Spring boot Framework). I see in kubernetes memory and CPU usage is continuously increasing.
My code is like this:
function(list <ids>){
for each id in ids{
expensiveFunction(id);
}
}
expensiveFunction(id){
//bring lot of data
// process data
//save data in db(transactional)
}
So, I believe when expensive function is completed for one ID, memory(lot of data objects) should be released(Java's automatic Garbage Collection).
So, why is memory increasing continuously? How can I avoid it, as it causing throttling of memory resulting in termination of application.
Is this is something to do with hiberante like caching data or something?