4 ms·
A memory leak can be unsafe though.
by spookie 10mo ago
A memory leak can be unsafe though.
- 201984 10mo agoThen why is Box::leak not marked unsafe?
- estebank 10mo ago"unsafe" or `unsafe`? One is the general meaning of the word, the latter is "it invokes undefined-behavior".
- spookie 10mo agoAs "unsafe". An example would be of how AMD GPUs some time ago didn't free a programs' last rendered buffers and you could see the literal last frame in its entirety. Fun stuff. Could've been clearer above.
- yuriks 10mo agoThat is not a memory leak though! That's using/exposing an uninitialized buffer, which can happen even if you allocate and free your allocations correctly. Leaking the buffer would prevent the memory region from being allocated by another application, and would in fact prevent that from happening. This is also something that Rust does protect against in safe code, by requiring initialization of all memory before use, or using MaybeUninit for buffers that aren't, where reading the buffer or asserting that it has been initialized is an unsafe operation.