Memory problem with OpenFire server

Hello,

some days ago I got openfire server memory problem, it was kept accepting new connections but all of the users were unable to join channels. The web interface was really slow and in the web interface it was visible that Java used all of the allocated memory (128mb). The machine is vm which has 512 mb of memory and around 1gb of space with lots of free disk space. We been thinking here to extract information from <admin_web_interface>/index.jsp , but unfortunatelly it is not possible, because when we try to wget it , it says that we need to turn on js first. So, there are two questions: is there a way to avoid it happen in the future and is there a way to monitor for java memory which is displayed in the admin interface ?

Thanks