Closed fsmoke closed 7 months ago
That is a common request. However shared_library
follows the std::shared_ptr
design. std::shared_ptr
does not have a release()
function.
Have you tried something like this:
std::vector<shared_library>& no_unload_registry() {
static std::vector<shared_library> reg;
return reg;
}
When there's a need to load library that does not unload till the end of program, do no_unload_registry().emplace_back(parameters_for_shared_library)
Duplicate of https://github.com/boostorg/dll/issues/68
I write custom .NET apphost application(for our project) and load into it coreclr.dll/so but this library(.NET VM) writed very tricky and not clean. They create several threads inside and there is no way to join them, so due destroying of shared_library object dtor unloads coreclr library and my app just cause access violation in random places, cos coreclr thread still alive, but code already unloaded!
I investigated original code of MS apphost - it seems there no FreeLibrary at all, so my suggession: they just left threads in the hope that system finish them and unload coreclr at the end of process.
But i don't know how make same behaviour with boost.dll - it seems shared_libarary has no any methods like detach or something like that.
PS .net project: https://github.com/dotnet/runtime