I don't think it's a memory leak. It's re-using the same space of the underling array. It's allocated. Dropping the Vec will release the memory.
In v1 you put in 128 containers is with each 1024 boxes.
Then v2 is taking out the first box out of each container, tossing the container and putting the box at the space where the container was, packing them.
The fact that capacity doubles when you remove the as u8 is... normal. You reuse the space, so you can fix 2u8 in the space of 1u16.
The problem here is more that this the optimization causes a Vec<T> -> Vec<Y> where sizeof(T) > sizeof(Y) to have much more capacity than expected.
Which IS a valid bug report. Bug again, not a memory leak.
In v1 you put in 128 containers is with each 1024 boxes.
Then v2 is taking out the first box out of each container, tossing the container and putting the box at the space where the container was, packing them.
The fact that capacity doubles when you remove the as u8 is... normal. You reuse the space, so you can fix 2u8 in the space of 1u16.
The problem here is more that this the optimization causes a Vec<T> -> Vec<Y> where sizeof(T) > sizeof(Y) to have much more capacity than expected.
Which IS a valid bug report. Bug again, not a memory leak.