I am loading an external class using a class-loader. I have a custom security manager that keeps track of what that class is allowed to do. This works fine. However, I would also like to monitor the memory requirements of that class. In particular, I would like to set a limit on the amount of memory this class may use. I am not able to edit the class in question.
If I understand it correctly, the only way to do this is to invoke a separate JVM. How do I do that? Would I need to wrap everything in a Process? T开发者_JAVA百科he class I need to execute does not have a main method - it is instantiated by the 'main' program. The idea is to run the program, then instantiate the external class in question and communicate with the resulting object (calling a selection of methods and passing some objects).
Thanks for your time.
You need to write a short program which has a main, which you can interact with e.g. via Socket/RMI/JMS even Input+OutputStream which will call the library for you.
精彩评论