Hi, It's because a subpage is always allocated at the leaf level? It's a recursive search, so returning -1 there will make the caller try other node whose state is ST_ALLOCATED_SUBPAGE. HTH, T -- https://twitter.com/trustin https://twitter.com/trustin_ko https://twitter.com/netty_project On Fri, Jul 1, 2016, at 11:55 AM, [email protected] wrote: > 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[1]. > For more options, visit https://groups.google.com/d/optout.
Links: 1. https://groups.google.com/d/msgid/netty/b64fa2d7-6b77-4762-8576-aba47bc65992%40googlegroups.com?utm_medium=email&utm_source=footer -- 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/1467618399.988500.656104313.0C33843F%40webmail.messagingengine.com. For more options, visit https://groups.google.com/d/optout.
