How to handle memory spike in App server

There was an incident where App server was down due to huge  Java process  process in the server had a huge memory spike which lead to the incident. what could be the reason behind memory spike and could it be handled in the future. We have resolved this by rebooting the server but request an answer for the above reqson  
2 answers

This can be caused by a lot of reasons. Maybe you have an infinite loop in your code, maybe you handle too many objects at once,…
First of all, you need to identify which part of your code caused the issue. There are tools that can help you with that.


You should investigate your code what could create of java processes.

- Are you using the process queue? Maybe you have configured a lot of queues which are using a lot of threads at the same time and are very busy. 

- Do you have a lot of schedules events which are running at the same time?

- Have you some actions which create background processes?

- Do you have a high frequently used webservice provided?