Closed cage2 closed 5 years ago
I think they'll be finalized when GC collects, but it won't? sqlite library seems to cache 16 queries by default, so small amount of queries may do not work.
Since CL-DBI prepared query is intended to be used repeatedly, finalizing them isn't great anyway :(
On Fri, Feb 01, 2019 at 12:16:36AM -0800, Eitaro Fukamachi wrote:
Hello!
Thank you for you reply!
Since CL-DBI prepared query is intended to be used repeatedly, finalizing them isn't great anyway :(
Well i think i can see the point here, i think it is a good point, indeed! :)
I have somehow managed to make the finalizer called but i got some other scary errors from the cl-sqlite library.
I have no solution unfortunately except an humble suggestion adding a 'free-query' function to release the memory allocated by a prepared query. This function could be added to the public API of this library.
AFAIK only for the sqlite3 driver this function actually would do something useful, but i think in the future some other database engine could benefit from this interface.
Thank you again! C.
On Fri, Feb 01, 2019 at 12:13:15AM -0800, Eitaro Fukamachi wrote:
I think they'll be finalized when GC collects, but it won't?
It does not, sadly. :(
Moreover the finalizer seems adding some more non deallocated memory.
Anyway FWIW:
(finalize query
(lambda ()
(when (slot-boundp conn-handle 'sqlite::handle)
(finalize-statement (query-prepared query)))))))
should became something like (some changing probably needed):
(let ((prepared (query-prepared query)))
(finalize query
(lambda ()
(when (slot-boundp conn-handle 'sqlite::handle)
(finalize-statement prepared)))))
But the (for me at least)OA, cl-sqlite begin spitting some terrible error messages. :(
Bye! C.
Hello!
i have written down some code about this idea of an explicit finalizer (for lacks of better word).
https://github.com/cage2/cl-dbi/tree/free-query-resource-poc
Maybe this could became an actual pull request if you agree.
Anyway, I hope this helps! :) Bye! C.
That looks good. As depending on GC seems to be troublesome, it could be implemented also for other drivers in the future.
On Thu, Apr 04, 2019 at 03:02:24AM -0700, Eitaro Fukamachi wrote:
Hello!
That looks good. As depending on GC seems to be troublesome, it could be implemented also for other drivers in the future.
Thank you for reviewing this! :) I'll submit a pull request as soon as possible.
Bye! C.
Closing because PR #47 is already merged.
Hello!
unfortunately i think the commit ea97e62327283bcf41d221f34e4537552fad28be
did not resolve the problem in:
https://github.com/fukamachi/cl-dbi/pull/43
to me seems that the added finalizer is not called and therefore the memory leak is here again.
the commit fcb4d2e3d0139fc8b6b9184ad9194d689058e949 seems OK to me, though.
Thank you for your work! C.