Home / Function/ free() — netty Function Reference

free() — netty Function Reference

Architecture documentation for the free() function in PoolSubpage.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  83bbb0dd_3188_7350_8354_910efc6a1ada["free()"]
  a6a571ea_fcf9_6eda_c073_f8d61fa999a3["PoolSubpage"]
  83bbb0dd_3188_7350_8354_910efc6a1ada -->|defined in| a6a571ea_fcf9_6eda_c073_f8d61fa999a3
  07ec09d1_e1cf_ca36_7a53_0a853eb310f7["setNextAvail()"]
  83bbb0dd_3188_7350_8354_910efc6a1ada -->|calls| 07ec09d1_e1cf_ca36_7a53_0a853eb310f7
  895e2ccf_f556_7741_93ea_be5be86704c9["addToPool()"]
  83bbb0dd_3188_7350_8354_910efc6a1ada -->|calls| 895e2ccf_f556_7741_93ea_be5be86704c9
  ece8cfac_ec12_b1cc_40c7_2768a79012a6["removeFromPool()"]
  83bbb0dd_3188_7350_8354_910efc6a1ada -->|calls| ece8cfac_ec12_b1cc_40c7_2768a79012a6
  style 83bbb0dd_3188_7350_8354_910efc6a1ada fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

buffer/src/main/java/io/netty/buffer/PoolSubpage.java lines 118–151

    boolean free(PoolSubpage<T> head, int bitmapIdx) {
        int q = bitmapIdx >>> 6;
        int r = bitmapIdx & 63;
        assert (bitmap[q] >>> r & 1) != 0;
        bitmap[q] ^= 1L << r;

        setNextAvail(bitmapIdx);

        if (numAvail ++ == 0) {
            addToPool(head);
            /* When maxNumElems == 1, the maximum numAvail is also 1.
             * Each of these PoolSubpages will go in here when they do free operation.
             * If they return true directly from here, then the rest of the code will be unreachable
             * and they will not actually be recycled. So return true only on maxNumElems > 1. */
            if (maxNumElems > 1) {
                return true;
            }
        }

        if (numAvail != maxNumElems) {
            return true;
        } else {
            // Subpage not in use (numAvail == maxNumElems)
            if (prev == next) {
                // Do not remove if this subpage is the only one left in the pool.
                return true;
            }

            // Remove this subpage from the pool if there are other subpages left in the pool.
            doNotDestroy = false;
            removeFromPool();
            return false;
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does free() do?
free() is a function in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/PoolSubpage.java.
Where is free() defined?
free() is defined in buffer/src/main/java/io/netty/buffer/PoolSubpage.java at line 118.
What does free() call?
free() calls 3 function(s): addToPool, removeFromPool, setNextAvail.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free