Description
The documentation for Vec
states:
Do not rely on removed data to be erased for security purposes. Even if you drop a
Vec
, its buffer may simply be reused by anotherVec
.
Here, "its buffer may simply be reused" is simply meant to refer to the behavior of the underlying allocator. But I have seen people with low-level experience be misled by this into thinking that the implementation of Vec
itself has its own global allocation cache. They then thought this cache was responsible for excess memory usage in their programs.
I'm not sure what the best way to clarify this would be. Part of the reason the current wording can be misleading is that "reused by another Vec
" suggests a mechanism specific to Vec
. On the other hand, it would also help to just explicitly mention the allocator. Here is a possible version that addresses both points, but it's more wordy than the current version:
Even if you drop a
Vec
, the allocator may reuse its buffer for anotherVec
or other allocation.