Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Conversation

@davidbrochart
Copy link
Collaborator

The drop(self) issues a warning:

warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
   --> src/y_transaction.rs:263:9
    |
263 |         drop(self);
    |         ^^^^^----^
    |              |
    |              argument has type `&mut YTransaction`
    |
    = note: use `let _ = ...` to ignore the expression or result
    = note: `#[warn(dropping_references)]` on by default

@davidbrochart
Copy link
Collaborator Author

I also tested the change with the following code, which doesn't seem to create any memory leak:

from y_py import YDoc

doc = YDoc()
text = doc.get_text("name")
t = "hello"
n = len(t)

while True:
    with doc.begin_transaction() as txn:
        text.insert(txn, 0, t)

    with doc.begin_transaction() as txn:
        text.delete_range(txn, 0, n)

@davidbrochart davidbrochart merged commit c0f3510 into y-crdt:main Sep 13, 2023
@davidbrochart davidbrochart deleted the drop branch September 13, 2023 14:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant