Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CBL-1440: Fix FLSlice memory leak #14

Merged
merged 1 commit into from
Dec 2, 2020
Merged

CBL-1440: Fix FLSlice memory leak #14

merged 1 commit into from
Dec 2, 2020

Conversation

bmeike
Copy link
Contributor

@bmeike bmeike commented Dec 2, 2020

This commit contains two changes:

  1. FLSliceResult now implements AutoCloseable. This is Java's contract that says "you must call close() on this, when you are done with it"
    Closing a core-owned object and failing to close a bindings-owned object just generate warnings. They no longer cause exceptions to be thrown.
  2. The FLSliceResult heap block allocated in the JNI is now freed. There are two cases:
    a) Java holds ownership of the FLSR: the allocated block is freed when Java frees is companion.
    b) Java passes ownership of the FLSR to Core: the allocated block is freed before the FLSR is returned to Core

@bmeike bmeike requested review from pasin and borrrden December 2, 2020 21:57
Copy link
Member

@borrrden borrrden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The switch of the boolean naming scared me at first but there is only one place that uses the isCoreOwned bool as true from what I can tell, so it is doing what it should.

@bmeike bmeike merged commit 67b4347 into master Dec 2, 2020
@bmeike bmeike deleted the bug/CBL-1440 branch December 2, 2020 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants