Allocation Control Question
In my application, I can't afford to have bm allocate after all initialization is done. How can I initialize the allocator or bvector such that it is guaranteed not to allocate further given a max size of N bits?
BM allocates in blocks of 64K bits (or less) on demand, so if you are not setting beyond N - it will not allocate. bvector will also do not allocate in between 0 and N if you are not setting bits in the block ranges. No special allocator is necessary.
So it seems that to "warm up" the allocator deterministically, I would have to pre-set a bit in each block range. Can you show a short example of doing that for an arbitrary N? For scale, my N may be in the millions.
Not really a full example but something like:
for (unsigned i = 0; i < N; i+=65536)
{
bv.set(i); // allocates a block, bit can be cleared immediately
}
Ok. Thank you. That would make a useful "reserve(nBits)" method. That's what I do on vectors and unordered_maps at init time.
On Thu, Jul 10, 2025 at 4:44 PM Anatoliy Kuznetsov @.***> wrote:
tlk00 left a comment (tlk00/BitMagic#82) https://github.com/tlk00/BitMagic/issues/82#issuecomment-3059200768
Not really a full example but something like:
for (unsigned i = 0; i < N; i+=65536) { bv.set(i); // allocates a block, bit can be cleared immediately }
— Reply to this email directly, view it on GitHub https://github.com/tlk00/BitMagic/issues/82#issuecomment-3059200768, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD4B47LGUGQ3W2G5GNN5MIL3H3NEHAVCNFSM6AAAAACA4YQOLKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTANJZGIYDANZWHA . You are receiving this because you authored the thread.Message ID: @.***>
Sure, good suggestion. Will add it soon.