Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve warning message when unloading a library still in use. #118

Open
wants to merge 2 commits into
base: rolling
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/class_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,11 @@ int ClassLoader::unloadLibraryInternal(bool lock_plugin_ref_count)

try {
if (plugin_ref_count_ > 0) {
CONSOLE_BRIDGE_logWarn(
"%s",
"class_loader.ClassLoader: SEVERE WARNING!!! "
"Attempting to unload library while objects created by this loader exist in the heap! "
"You should delete your objects before attempting to unload the library or destroying "
"the ClassLoader. The library will NOT be unloaded.");
CONSOLE_BRIDGE_logWarn("class_loader.ClassLoader: SEVERE WARNING!!!\n"
"Attempting to unload %s\n"
"while objects created by this library still exist in the heap!\n"
"You should delete your objects before destroying the ClassLoader. "
"The library will NOT be unloaded.", library_path_.c_str());
Comment on lines +153 to +157
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In most cases is this a side-affect of the ClassLoader object going out of scope and being destroyed while the plugin(s) it has loaded are still in scope?

Would it be helpful to add this to the error message?

Please verify that the lifetime of the ClassLoader for {} is at least as long as the lifetime of all plugins loaded by that ClassLoader.

} else {
load_ref_count_ = load_ref_count_ - 1;
if (load_ref_count_ == 0) {
Expand Down