Platform
ESP32
IDE / Tooling
Arduino (IDE/CLI)
What happened?
I have the following code
AsyncCallbackWebHandler& RawRequest::onServer() {
// PAGE 'raw data' http://[IP-DO-ESP]/raw?page={page}
return this->webServer->on("/raw", HTTP_GET, [this](AsyncWebServerRequest *request) {
STARTING_SERVER_PROCESSING();
uint16_t limit = 10;
uint16_t currentPage = 1;
if (request->hasParam("page")) {
currentPage = request->getParam("page")->value().toInt();
if (currentPage < 1) {
currentPage = 1;
}
}
uint32_t totalPages = this->getDataMonitor()->getTotalPages(limit);
std::list<Sample> samples = this->getDataMonitor()->selectSamples(currentPage, limit);
Serial.println("Current Page: " + String(currentPage) + " Total Pages: " + String(totalPages));
RawPage rawPage = RawPage(
DATABASE,
currentPage,
totalPages,
limit,
&samples
);
request->send(200, "text/html", rawPage.page());
FINISH_SERVER_PROCESSING();
});
}
If rawPage is created with new
AsyncCallbackWebHandler& RawRequest::onServer() {
// PAGE 'raw data' http://[IP-DO-ESP]/raw?page={page}
return this->webServer->on("/raw", HTTP_GET, [this](AsyncWebServerRequest *request) {
STARTING_SERVER_PROCESSING();
uint16_t limit = 10;
uint16_t currentPage = 1;
if (request->hasParam("page")) {
currentPage = request->getParam("page")->value().toInt();
if (currentPage < 1) {
currentPage = 1;
}
}
uint32_t totalPages = this->getDataMonitor()->getTotalPages(limit);
std::list<Sample> samples = this->getDataMonitor()->selectSamples(currentPage, limit);
Serial.println("Current Page: " + String(currentPage) + " Total Pages: " + String(totalPages));
Page *rawPage = new RawPage(
DATABASE,
currentPage,
totalPages,
limit,
&samples
);
request->send(200, "text/html", rawPage.page());
delete rawPage
FINISH_SERVER_PROCESSING();
});
}
Even with the delete function at the end, a memory leak still occurs.
AchcarLucas/Flow-Control-System@2ba8941
Above is the commit I had to make (converting everything to local) to remove the memory leak.
Stack Trace
Memory Leak
Minimal Reproductible Example (MRE)
Memory Leak
I confirm that:
Platform
ESP32
IDE / Tooling
Arduino (IDE/CLI)
What happened?
I have the following code
If rawPage is created with new
Even with the delete function at the end, a memory leak still occurs.
AchcarLucas/Flow-Control-System@2ba8941
Above is the commit I had to make (converting everything to local) to remove the memory leak.
Stack Trace
Memory Leak
Minimal Reproductible Example (MRE)
Memory Leak
I confirm that: