问题描述
我有一个网站,某些用户可以在其中上传他的dll.我需要从该dll创建实例并调用特定方法.而且,我需要在1个进程中使用多个dll来执行此操作,因此我不能选择使用System.Diagnostics.Process.
I have a website where some user can upload his dll. I need to create an instance from this dll and call a specific method. Moreover, I need to do it with several dll's in 1 process, so it is not an option for me to use System.Diagnostics.Process.
是否有一种方法可以确定此方法调用在我的应用程序运行时使用了多少内存或限制了它?预先感谢您的帮助
Is there a way to determine how much memory does this method call use or limit it in my application runtime?Thanks in advance for any help
推荐答案
.Net中的内存使用情况很难衡量-这取决于很多因素,例如是否运行垃圾回收,已加载多少框架等
Memory usage in .Net is very difficult to gauge - It will depend on a lot of factors like whether garbage collection run, how much of the framework has been loaded, etc.
您可以使用性能计数器
假设您已经考虑了在半信任环境中运行用户代码的安全隐患,则需要使用 AppDomain 来加载DLL-这样就可以卸载它,而无需重新启动整个网站/工作人员池
Assuming for a moment you've already considered the security implications of running a users code in a semi-trusted environment, you need to use an AppDomain to load the DLL - That way it can be unloaded without restarting the whole website / worker pool
这篇关于如何确定我的.NET应用程序中的内存使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!