On Thu, Jan 6, 2022 at 7:00 AM Trent Nelson <trent@trent.me> wrote:
I did some research on this a few years back. I was curious what sort of "max reference counts" were encountered in the wild, in long-running real life programs. For the same reason: I wanted to get some insight into how many unused bits could possibly be repurposed for future shenanigans (I had PyParallel* in the mind at the time).
I think we can assume the upper bound of the reference count is same to upper bound of the pointer. On 32bit machine, memory space is 2**32 byte, and pointers take 4bytes. And NULL can not store pointer. So upper bound of refcnt is 2**30-1. So we have two free bits in the refcnt. On 64bit machine, we have at least four free bits as same reason. Regards, -- Inada Naoki <songofacandy@gmail.com>