I have an HTTP server (cpp-httplib library) that creates and should destroy an instance of the OmmConsumer class when processing a POST request. The library creates 10 threads to handle requests, and it feels like the OmmConsumer instance is not fully destroyed in each of them. Am I doing something wrong or is there a memory leak?
void handle_post_request(const httplib::Request &req, httplib::Response &res){
try{
OmmConsumer consumer(OmmConsumerConfig().username("username").host("127.0.0.1:1234"));
res.set_content("OK", "application/json");
}
catch (const std::exception &excp){
res.set_content("BAD", "application/json");
}
}
int main(int argc, char *argv[]){
httplib::Server server;
auto endpoint = "/test/";
auto host = "0.0.0.0";
auto port = 8080;
try{
server.Post(endpoint, handle_post_request);
}
catch (const std::exception &e){
return 54;
}
server.listen(host, port);
}
Before requests:
After requests: