cont : release loader staging buffer on shrink

This commit is contained in:
Aman Gupta committed 2026-10-28 01:03:43 +08:00
1 parent 34286275fc
commit 3a95ed36f6
1 file changed
+2 -1
+2 -1
View File
@@ -1820,7 +1820,8 @@ bool llama_model_loader::load_all_data(
// tensors come biggest-first: shrink the buffer when it gets too large, so peak memory stays close to one tensor
if (read_buf.size() < buf_size || read_buf.size() > 2*buf_size) {
read_buf = {};
// free the old buffer first, `read_buf = {}` would keep its capacity
read_buf = std::vector<no_init<uint8_t>>();
read_buf.resize(buf_size);
}
uint8_t * read_dst = (uint8_t *) GGML_PAD((uintptr_t) read_buf.data(), align);