oatpp / example-crud

A complete example of a "CRUD" service (UserService) built with Oat++.
https://oatpp.io/
Apache License 2.0
100 stars 63 forks source link

Memory leak with database / database connection #8

Closed ktnr closed 3 years ago

ktnr commented 3 years ago

After writing a simple first test for adding a user to the database, I get a memory leak. Specifically when calling UserService::createUser(), I get the following. But it occurs for every interaction with the database, even a simple SELECT.

 D |2020-12-27 16:09:45 1609081785691030| test:insert oatpp-swagger tests here
 I |2020-12-27 16:09:45 1609081785696638| MyTag:START...
 D |2020-12-27 16:09:45 1609081785837194| UserDb:Migration - OK. Version=1.
 D |2020-12-27 16:09:45 1609081785843605| ClientServerTestRunner:Running server on port 0. Timeout 600000000(micro)
 D |2020-12-27 16:09:45 1609081785901287| AAA:new userId=2
 D |2020-12-27 16:09:45 1609081785925135| ClientServerTestRunner:Finished with time 81561(micro). Stopping server...
 E |2020-12-27 16:09:46 1609081786943157| MyTag:FINISHED - failed, leakingObjects = 4
 V |2020-12-27 16:09:46 1609081786973611| Pool:name: 'Small_String_Pool_1' [1(objs)]

It even occurs when there is no interaction with the database, as long as DatabaseComponent is instantiated in the tests:. But with one less leaked object: E |2020-12-27 16:31:22 1609083082386201| MyTag:FINISHED - failed, leakingObjects = 3

This probably requires a fix in oatpp-sqlite. Unfortunately, I couldn't narrow it down more.

Other than that, works like a charm. Great work on all fronts!

lganzzzo commented 3 years ago

Hey @ktnr ,

Thanks for the issue and for the feedback!

Please post the code of your test here, or you may just create a PR for that.

At the moment, not having seen your code, It seems like some of the objects from config may have been left in the memory.

Regards, Leonid

lganzzzo commented 3 years ago

Fixed in https://github.com/oatpp/example-crud/pull/10