Skip to content

Potential Memory Leak in Connection Management Due to Missing Database Cleanup #9

@xiezhaokai

Description

@xiezhaokai

in ConnectionPrivate::ConnectionPrivate , this->db = QSqlDatabase::addDatabase(config.driver, dbId); will add different ID database. when refresh , sometime, a new sharedPtr will replace the older one. But no QSqlDatabase::removeDatabase in found either in the deconstructor nor the other place. I think this may lead to a memory leak .
In ConnectionPrivate::ConnectionPrivate, the code calls:

this->db = QSqlDatabase::addDatabase(config.driver, dbId);

This creates database connections with different identifiers. However, during refreshoperations, a new shared pointer sometimes replaces the old connection without proper cleanup.The destructor and other code locations lack calls to QSqlDatabase::removeDatabase for the old connections. This oversight may lead to accumulated database connections and potential memory leaks over time, as orphaned QSqlDatabase objects are not properly released.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions