hey,

i have read the source code about the memo allocation, and i found a 
problem which is when we allocate the sub-page ,if the element size of the 
page does not equal  the normalized 
size , it will return -1(the part  i have already marked as read as below ) 
,which means the allocation is failed , the thing i am wandering is that 
why it is marked as failed directly ,why not search for another parent 
node,then do the
allocation.

 private long allocateSubpage(int normCapacity, int curIdx, int val) {
        int state = val & 3;
        if (state == ST_BRANCH) {
            int nextIdx = curIdx << 1 ^ nextRandom();
            long res = branchSubpage(normCapacity, nextIdx);
            if (res > 0) {
                return res;
            }

            return branchSubpage(normCapacity, nextIdx ^ 1);
        }

        if (state == ST_UNUSED) {
            return allocateSubpageSimple(normCapacity, curIdx, val);
        }

        if (state == ST_ALLOCATED_SUBPAGE) {
            PoolSubpage<T> subpage = subpages[subpageIdx(curIdx)];
            int elemSize = subpage.elemSize;
            if (normCapacity != elemSize) {
                return -1;
            }

            return subpage.allocate();
        }

        return -1;
    }

-- 
You received this message because you are subscribed to the Google Groups 
"Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/netty/b64fa2d7-6b77-4762-8576-aba47bc65992%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to