开发者

Memory limit for external class-loaded Java class

开发者 https://www.devze.com 2023-03-20 23:25 出处:网络
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 m

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消