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

fix: tow code blocks cause memory leak. #312

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion deepin-system-monitor-main/model/accounts_info_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ void AccountsInfoModel::onSessionRemoved(const QString &in0, const QDBusObjectPa
void AccountsInfoModel::updateUserList(const QStringList &userPathList)
{
qInfo() << "AccountsInfoModel updateUserList line 61" << "updateUserList begins!" ;
// 释放构造对象
qDeleteAll(m_userMap.values());
m_userMap.clear();

for (QString userPath : userPathList) {
QDBusInterface *userDBus = new QDBusInterface(common::systemInfo().AccountsService, userPath, common::systemInfo().UserInterface, QDBusConnection::systemBus(), this);
User *newUser = new User;
Expand All @@ -90,10 +93,11 @@ void AccountsInfoModel::updateUserList(const QStringList &userPathList)
}
qInfo() << "AccountsInfoModel updateUserList line 78" << "get user info of :" << newUser->name();
m_userMap.insert(newUser->name(), newUser);

delete userDBus;
}
}


void AccountsInfoModel::updateUserOnlineStatus()
{
qInfo() << "AccountsInfoModel updateUserOnlineStatus line 88" << "updateUserOnlineStatus begins!" ;
Expand Down
5 changes: 4 additions & 1 deletion deepin-system-monitor-main/process/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,10 @@ void Process::readSockInodes()
if (!stat(fdp, &sbuf)) {
// get inode if it's a socket descriptor
if (S_ISSOCK(sbuf.st_mode)) {
d->sockInodes << sbuf.st_ino;
// not append repeat data, may memory leak.
if (!d->sockInodes.contains(sbuf.st_ino)) {
d->sockInodes << sbuf.st_ino;
}
}
} // ::if(stat)
} // ::if(isdigit)
Expand Down
4 changes: 3 additions & 1 deletion deepin-system-monitor-plugin-popup/process/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,9 @@ void Process::readSockInodes()
if (!stat(fdp, &sbuf)) {
// get inode if it's a socket descriptor
if (S_ISSOCK(sbuf.st_mode)) {
d->sockInodes << sbuf.st_ino;
if (!d->sockInodes.contains(sbuf.st_ino)) {
d->sockInodes << sbuf.st_ino;
}
}
} // ::if(stat)
} // ::if(isdigit)
Expand Down
Loading