I want to run several REST web applications inside one Java process to save memory and scale easily with help of Akka. I would like to estimate how much memory each request handler consume and detect these dangerous for the entire system.
Is it possible to monitor memory usage in almost real time inside that process and find out how much memory is used be each request handler? What I need to achieve that? Are there any tools?
Is it possible to catch
out of memory exception
and based on memory usage do something, for example crash only request handlers exceeding assumed memory limit? If so, what could be bad with that?