OpenAPITools / OpenAPITools/openapi-generator

[BUG][cpp-qt-client] Client requests leaking memory

Open
#12,552 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: QT Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • [ x] Have you provided a full/minimal spec to reproduce the issue?

  • [x ] Have you validated the input using an OpenAPI validator (example)?

  • Have you tested with the latest master to confirm the issue still exists?
    ->no, but the changelog does not indidcate any changes in that area

  • [x ] Have you searched for related issues/PRs?

  • [x ] What's the actual output vs expected output?
    at least get and put requests are leaking memory

Description

I have many API calls over extened time, each request leaking a small ammount of memory, at about 1k request/sec causing to leak about 20MB in 10min

openapi-generator version

5.4.0, 6.00 does not seem to have changes on that component so I have not tried

OpenAPI declaration file content or url

VHCx64CtrREST.json.txt

Generation Details

default installation, using qt 5.14.1

Steps to reproduce

using the example code from the generated readme.md to make an reqest in infinte loop just in the main of and Qt appliaktion (before UI/Mainwindows is instantiated) and also from within mainWindow. i tried with one get and one put request as example, both yield the same leakage in two differnt ways:

while(true)
{
get_synchronous_setting("0x6601","0x03");
}

and wrapping in additional event loop:

  QEventLoop loop;
    QTimer* test= new QTimer();
    connect(test, &QTimer::timeout,&loop,[&](){
        get_synchronous_setting("0x6601","0x03");
    });
    test->start(1);
    loop.exec();

with get_synchronous_setting defined analogous to the readme.md:

        OAIDefaultApi apiInstance;
        QEventLoop loop;
        QObject::connect(&apiInstance, &OAIDefaultApi::getCanOdAccessIntSignal, [&](qint32 val) {
            loop.quit();
        });

        QObject::connect(&apiInstance, &OAIDefaultApi::getCanOdAccessIntSignalE, [&](qint32 summary,QNetworkReply::NetworkError, QString error_str) {
            loop.quit();
        });

        apiInstance.getCanOdAccessInt(idx,sidx);
        QTimer::singleShot(5000, &loop, &QEventLoop::quit);
        loop.exec();

Suggest a fix

i was digging around a bit but I could not figure out where it is leaking. maybe related to deleteLater of the qNetworkReply??

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated readme.md example and reproduce the leak using the provided get_synchronous_setting loop, Qt 5.14.1, and the attached OpenAPI declaration. Compare the GET and PUT paths, including the QNetworkReply cleanup path, and verify that repeated requests no longer increase memory usage over the reported workload.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.