FreeOnFinalize Class — netty Architecture
Architecture documentation for the FreeOnFinalize class in PoolThreadCache.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 2da6a301_6e89_e4ee_919c_feaf2800852b["FreeOnFinalize"] 2a7d96ed_6f58_dca1_f092_d9cac20e28ae["PoolThreadCache.java"] 2da6a301_6e89_e4ee_919c_feaf2800852b -->|defined in| 2a7d96ed_6f58_dca1_f092_d9cac20e28ae 14ca16ec_3c48_a125_2380_030b82e59d0e["FreeOnFinalize()"] 2da6a301_6e89_e4ee_919c_feaf2800852b -->|method| 14ca16ec_3c48_a125_2380_030b82e59d0e 6a490f6b_0a0e_531d_db52_9bb29522c8ab["finalize()"] 2da6a301_6e89_e4ee_919c_feaf2800852b -->|method| 6a490f6b_0a0e_531d_db52_9bb29522c8ab
Relationship Graph
Source Code
buffer/src/main/java/io/netty/buffer/PoolThreadCache.java lines 474–498
private static final class FreeOnFinalize {
private volatile PoolThreadCache cache;
private FreeOnFinalize(PoolThreadCache cache) {
this.cache = cache;
}
/// TODO: In the future when we move to Java9+ we should use java.lang.ref.Cleaner.
@SuppressWarnings({"FinalizeDeclaration", "deprecation"})
@Override
protected void finalize() throws Throwable {
try {
PoolThreadCache cache = this.cache;
// this can race with a non-finalizer thread calling free: regardless who wins, the cache will be
// null out
this.cache = null;
if (cache != null) {
cache.free(true);
}
} finally {
super.finalize();
}
}
}
Source
Frequently Asked Questions
What is the FreeOnFinalize class?
FreeOnFinalize is a class in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/PoolThreadCache.java.
Where is FreeOnFinalize defined?
FreeOnFinalize is defined in buffer/src/main/java/io/netty/buffer/PoolThreadCache.java at line 474.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free