You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by GitBox <gi...@apache.org> on 2022/06/24 15:28:44 UTC

[GitHub] [incubator-kvrocks] PragmaTwice opened a new issue, #663: Use RAII to eliminate some trivial manual deallocation

PragmaTwice opened a new issue, #663:
URL: https://github.com/apache/incubator-kvrocks/issues/663

   ### Search before asking
   
   - [X] I had searched in the [issues](https://github.com/apache/incubator-kvrocks/issues) and found no similar issues.
   
   
   ### Motivation
   
   There are many manual memory (or other system resources like file) allocation and deallocation such as `new`/`delete` in kvrocks.
   
   Memory management is a complex topic (after RC/tracing GC is involved quickly) and there are some smart pointers like `unique_ptr`, `shared_ptr` in C++ to abstract a specific way to manage resources.
   
   For some trivial scenario which do not require to share objects, we can do it via `unique_ptr`, which is a zero-overhead abstraction.
   
   We can switch some manual deallocations to `unique_ptr` to make the code more maintainable and less prone to memory leaks.
   
   NOTE: We try to use `unique_ptr` instead of creating our own RAII class types because `unique_ptr` has good semantics: it prohibits copy construction and only allows move construction, which keeps us from accidentally sharing objects and causing Use After Free or Double Free.
   
   ### Solution
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] PragmaTwice commented on issue #663: Use `unique_ptr` to eliminate some trivial manual deallocation

Posted by GitBox <gi...@apache.org>.
PragmaTwice commented on issue #663:
URL: https://github.com/apache/incubator-kvrocks/issues/663#issuecomment-1288042008

   Closed. Will create new issue if more manual deallocations are found.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] PragmaTwice commented on issue #663: Use `unique_ptr` to eliminate some trivial manual deallocation

Posted by GitBox <gi...@apache.org>.
PragmaTwice commented on issue #663:
URL: https://github.com/apache/incubator-kvrocks/issues/663#issuecomment-1242936181

   I think most of trivial manual deallocation is removed, but there still remains some raw memory allocation or fd allocation.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] PragmaTwice closed issue #663: Use `unique_ptr` to eliminate some trivial manual deallocation

Posted by GitBox <gi...@apache.org>.
PragmaTwice closed issue #663: Use `unique_ptr` to eliminate some trivial manual deallocation
URL: https://github.com/apache/incubator-kvrocks/issues/663


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] tisonkun commented on issue #663: Use `unique_ptr` to eliminate some trivial manual deallocation

Posted by GitBox <gi...@apache.org>.
tisonkun commented on issue #663:
URL: https://github.com/apache/incubator-kvrocks/issues/663#issuecomment-1287996842

   @PragmaTwice is there a way we can find and list them out here? Otherwise, it seems this proposal stalls.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] tisonkun commented on issue #663: Use `unique_ptr` to eliminate some trivial manual deallocation

Posted by GitBox <gi...@apache.org>.
tisonkun commented on issue #663:
URL: https://github.com/apache/incubator-kvrocks/issues/663#issuecomment-1242877583

   @PragmaTwice is there any remaining works and do you want to continue driving this effort?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] PragmaTwice commented on issue #663: Use `unique_ptr` to eliminate some trivial manual deallocation

Posted by GitBox <gi...@apache.org>.
PragmaTwice commented on issue #663:
URL: https://github.com/apache/incubator-kvrocks/issues/663#issuecomment-1165711567

   > I'd like to do it.
   
   Thanks, feel free to submit a PR.
   
   Since this issue may be divided into many PRs, everyone can directly submit a PR for a specific part, so I think it would be better not to assign this issue to a specific person.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] jackwener commented on issue #663: Use `unique_ptr` to eliminate some trivial manual deallocation

Posted by GitBox <gi...@apache.org>.
jackwener commented on issue #663:
URL: https://github.com/apache/incubator-kvrocks/issues/663#issuecomment-1165705438

   I'd like to do it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org