doc: clarify expected memory management strategy
Right now, docs don't make it clear when exactly does it become okay to free memory belonging to `uv_handle_t`. It's only stated that `uv_close` must be called before freeing the memory, which is a source of confusion for new users: they call `uv_close(handle, NULL)`, then free the memory (see e.g. #2078, https://stackoverflow.com/q/25615340). PR-URL: https://github.com/libuv/libuv/pull/2087 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
c5593b51dc
commit
5b64cc60b9
@ -140,6 +140,8 @@ API
|
|||||||
|
|
||||||
Request handle to be closed. `close_cb` will be called asynchronously after
|
Request handle to be closed. `close_cb` will be called asynchronously after
|
||||||
this call. This MUST be called on each handle before memory is released.
|
this call. This MUST be called on each handle before memory is released.
|
||||||
|
Moreover, the memory can only be released in `close_cb` or after it has
|
||||||
|
returned.
|
||||||
|
|
||||||
Handles that wrap file descriptors are closed immediately but
|
Handles that wrap file descriptors are closed immediately but
|
||||||
`close_cb` will still be deferred to the next iteration of the event loop.
|
`close_cb` will still be deferred to the next iteration of the event loop.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user