Tagged articles
garbage-collection
15 articles · Page 1 of 1
This article explains Python's automatic garbage collection mechanisms, including reference counting and cyclic garbage collection, and presents ten practical code snippets demonstrating how to inspect reference counts, list objects, trace memory usage, and employ profiling tools such as tracemalloc, memory_profiler, pympler, and objgraph to detect leaks and optimize memory usage.
code-examplesgarbage-collectionmemory-management
0 likes · 4 min read


21CTOJul 28, 2023 · Backend Development
After learning Rust, I created a toy Java Virtual Machine called rjvm, open‑sourced on GitHub, detailing its architecture, class file parsing, bytecode execution, value modeling, instruction handling, exception processing, and a simple stop‑the‑world garbage collector, while sharing insights and code snippets.
JVMbytecodegarbage-collection
0 likes · 15 min read

The article explains how a Java ThreadPoolExecutor can retain hundreds of waiting threads when shutdown is omitted, analyzes the GC‑root relationship of running threads, and demonstrates through code and JVisualVM screenshots that invoking shutdown or shutdownNow properly interrupts idle workers, removes them from the pool, and allows both the worker threads and the thread‑pool object to be garbage‑collected.
JavaShutdownThreadPoolExecutor
0 likes · 12 min read

The article explains that Java's enum values() method creates a new array on each call by cloning an internal $VALUES field, which contradicts object‑reuse principles and adds GC pressure, and it suggests caching the returned array when frequent calls are needed.
CachingEnumbytecode
0 likes · 2 min read

This article explains JavaScript's memory allocation across code, stack, and heap spaces, details how different data types are stored, describes garbage collection mechanisms, and provides practical steps to detect and fix memory leaks, including a React-specific example.
garbage-collectionmemory-leakmemory-management
0 likes · 18 min read

This article explains the misconception that manually assigning null to unused objects always helps Java garbage collection, demonstrates with concrete JVM examples how stack slots and reachability analysis affect object reclamation, and shows when null‑assignment or slot reuse actually makes a difference.
Javagarbage-collectionmemory-management
0 likes · 10 min read

This article explains how Java objects are stored in memory, analyzes the heap layout, object header, instance data, and padding, demonstrates the byte size of a new Object() with and without compressed OOPs, and discusses object access methods and garbage‑collection regions.
Memory LayoutObject Sizecompressed-oops
0 likes · 12 min read

This article provides a comprehensive guide to Java object creation, covering implicit, no‑argument, and argument constructors, initialization blocks, static initialization, default value guarantees, visibility rules, garbage collection, finalizers, and common construction patterns such as singleton, helper, factory, and dependency injection.
Initializationconstructorsdependency-injection
0 likes · 17 min read

This article explains the JVM garbage collection mechanism, covering which memory areas are collected, how object reachability is determined, the main GC algorithms, generational collection theory, and JVM heap layout, providing essential knowledge for Java performance tuning.
GC algorithmsJVMJVM tuning
0 likes · 20 min read

This article explains PHP's garbage collection mechanism, detailing how reference counting works, the role of zval structures, the identification and reclamation process, and provides source code insights to compare PHP's approach with Java's garbage collection.
PHPReference Countingbackend-development
0 likes · 9 min read

This article demystifies the common advice of setting unused objects to null in Java by examining JVM garbage collection, runtime stack behavior, and stack slot reuse, demonstrating through code examples how null assignments or variable reuse affect object reclamation.
garbage-collectionmemory-managementnull assignment
0 likes · 9 min read

This tutorial explains what Java memory leaks are, why they happen despite garbage collection, shows common leak patterns such as static fields, unclosed resources, improper equals/hashCode, inner classes, finalize, constant strings and ThreadLocal, and provides practical detection and prevention techniques.
Memory Leakbest-practicesgarbage-collection
0 likes · 16 min read

This article explains Java's garbage collection fundamentals, covering JVM memory layout, key heap parameters, object liveness determination, and the main GC algorithms—Mark‑Sweep, Copying, and Mark‑Compact—while providing practical insights for interview preparation.
AlgorithmsGCInterview
0 likes · 10 min read

The article explains why the JVM uses a generational heap, describes the structure and operation of the young generation—including Eden and two Survivor spaces—illustrates object lifecycles, the role of Survivor spaces in preventing fragmentation, and outlines related JVM tuning parameters.
JavaSurvivor Spacegarbage-collection
0 likes · 10 min read

This tutorial explains how Java's automatic garbage collection works, covering the roles of System.gc(), memory regions such as Eden, Survivor and Old generations, reference types, object finalization, and includes code examples that illustrate GC eligibility and OutOfMemoryError scenarios.
FinalizeOutOfMemoryErrorgarbage-collection
0 likes · 10 min read
