ASP.NET Web 服务使用 P/Invoke 调用非托管代码。多个webservice请求之间会不会出现内存问题?
有一个 ASP.NET Web 服务,每次调用 Web 服务时都会执行 LoadLibrary() 调用来加载非托管 .dll,然后 P/Invokes 非托管 .dll 中的许多函数。
ASP.NET 用于服务多个并发请求的线程模型是否意味着可能存在内存问题,即后续 Web 服务请求会占用非托管代码内分配的内存?
不同的 Web 服务请求是否在非托管代码中分配了自己的内存空间,或者它们是否在同一空间上发生冲突?
谢谢!
There is an ASP.NET webservice that peforms a LoadLibrary() call to load an unmanaged .dll on each call to the webservice and then P/Invokes a number of functions in the unmanaged .dll.
Does the threading model used by ASP.NET to service multiple simultaneous requests mean that there can potentially be memory problems whereby the memory allocated inside the unmanaged code is stepped on by subsequent webservice requests?
Are different webservice requests allocated their own memory space within the unmanaged code or are they clashing over the same space?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为 p/invoke 调用分配的内存取决于特定的调用,但总的来说,只要您正确清理非托管资源,就不应该有问题,因为垃圾收集器不会。从这个意义上说,ASP.NET 应用程序就像任何其他多线程应用程序一样。
Where the memory allocated for p/invoke calls depends on the particular call, but overall there shouldn't be a problem as long as you clean up unmanaged resources properly, because the garbage collector wont. In that sense an ASP.NET application is just like any other multi-threaded application.