在嵌套Parallel.For
中,我动态加载/卸载不同的 DLL。我注意到在 'child' 的末尾没有释放内存Parallel.For
。记忆似乎在 'root'之后Parallel.For
被释放。
Parallel.For(0, 100, j =>
{
// Do stuffs
Parallel.For(0, maxIter, i =>
{
// Dynamically load DLL file
NativeMethods.LoadLibrary(...)
// Do stuffs with the DLL
... (call compute method)
// Dynamically unload DLL file
NativeMethods.FreeLibrary(...)
});
// Do stuffs
}
// Do stuffs (DLL Memory seems to be release only here, not before)
我已经在许多具有不同名称的 DLL 中克隆了一个 DLL(复制文件并重命名它)。每个NativeMethods.LoadLibrary(...)
加载这些 DLL 之一。/MD
DLL 是使用选项编译的 c++ 非托管代码。每个库只被一个线程使用Parallel.For
你能解释一下吗?
如何释放 DLL 内存Parallel.For
?