-
Notifications
You must be signed in to change notification settings - Fork 4
Fix/Logger memory leak #31
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
base: develop
Are you sure you want to change the base?
Conversation
+ primary1->getName() + LOG4CXX_STR("].")); | ||
this->primary = primary1; | ||
+ primary1.lock()->getName() + LOG4CXX_STR("].")); | ||
primary_ = primary1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SNiukalov maybe after you renamed primary -> primary_
it's time to rename primary1 -> primary
? or primary1
have some special meaning. And the same below with backup1
@@ -155,18 +155,18 @@ AppenderList Logger::getAllAppenders() const { | |||
} | |||
} | |||
|
|||
AppenderPtr Logger::getAppender(const LogString& name1) const { | |||
AppenderWeakPtr Logger::getAppender(const LogString& name1) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SNiukalov why is name1
?
Guys. Could someone explain how the weak_ptr usage allows to avoid memory leaks? I would say that this is crucial to use raw pointer (or better reference here) due to performance matter. Logging the stuff is time consuming operation. When you create the shared pointer to log the stuff out during every attempt to log what will happen with performance? |
@AGaliuzov struct B; In this case, destructors for A and B will not be called. |
I know how the stuff works in general. Here I believe you try to cover the real problem bu substituting shared to weak. Idea of the logger is to have the only logger instance. Could you show SDL code where we have such a cross reference? May be to worth to fix exactly this place.? |
@AGaliuzov |
I wouldn't say weak_ptr is optimisation. Still you need to make it shared all the time. To me the weak_ptr approach here not needed. But let other guys to tel their opinion. |
According to diagrams seems the pool fix does the trick even without extra efforts related to pointers replacement. Perhaps, it is worth to integrate this fix only? |
@SNiukalov could you please attach diagrams of memory usage with applying each commit |
@AGaliuzov using shared instead of weak pointers may cause memory leaks due to cross-references. Weak pointers may fix the issue. Our goal, for now, is to avoid critical memory leaks inside the logger. I believe that our version of log4cxx is critically outdated and the best solution would be to implement https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0046-implement-logger-abstraction.md and apply another more robust logger with better performance and support. Supporting of old log4cxx version is not our goal, it requires many resources, so we can fix for now critical issues, and try to push the correct solution. In this PR I can see several solutions that are combined, |
May cause and cause with proof - are different things. Don't you agree? You could even say - using shared pointer causes memory leaks. Or even more - allocating the memory may cause memory leak. Nut there is one big |
@LuxoftAKutsan @AGaliuzov @AByzhynar @mvorobio |
Please pay attention to different scales on the diagrams above. It is difficult to make such a conclusion visually. |
@LuxoftAKutsan @AGaliuzov @AByzhynar @mvorobio Guys, please, to tell your opinion. |
From my point all options with the pool fix give almost identical results regarding memory usage. |
@LuxoftAKutsan @AGaliuzov @AByzhynar |
|
In this case, the internal memory pool was used instead of the external one. The internal memory pool for TelnetAppender will be cleared only when this object is deleted. Therefore, we have memory accumulation. External will be cleared immediately after exiting the forced logging function.
edd57a3
to
c9a5be7
Compare
@LuxoftAKutsan @AByzhynar @mvorobio please check the latest updates |
@SNiukalov looks like we have complete internal review. You are free to create review in sdl_core. |
Fixes #5239
Jira task
PR in smartdevicelink
This PR is ready for review.
Risk
This PR makes no API changes.
Testing Plan
ATF scripts
Summary
Updated log4cxx library to avoid leak and accumulation memory.
Bug Fixes
CLA