Skip to content

Avoid leaking vecs#3

Open
nappa85 wants to merge 2 commits into
allevo:mainfrom
nappa85:no_vec
Open

Avoid leaking vecs#3
nappa85 wants to merge 2 commits into
allevo:mainfrom
nappa85:no_vec

Conversation

@nappa85
Copy link
Copy Markdown

@nappa85 nappa85 commented Nov 5, 2025

This PR avoids using Vecs and then leaking it.

Storage is initialized in a const fashion when creating the allocator, and will live in the same static address, not on the heap. This should increase performances, but I have no benchmarks to demonstrate it (I also understand that performances is not a main goal of this allocator).

I've noticed a logic flaw, and I want to discuss it with you:

  • old version was recreating the storage at every start_track, but not resetting allocation_logs_pointer and deallocation_logs_pointer, thus if someone would have called start_track multiple times (obviously respecting the safety guarantees of never calling it concurrently) he could have received the overflow panic even if the buffer wasn't really full
  • new version never empties the storage, thus calling start_track multiple times will always keep previous run in memory

A third behavior could be implemented, if desired, emptying the storage and resetting the counters, to allow multiple indepentent runs.

Unrelated, but I would also suggest to use clippy while developing, I've took the initiative to apply some clippy lints on first commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant