<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ramanjaneyulu Boya</title>
    <description>The latest articles on DEV Community by Ramanjaneyulu Boya (@ramthearchitect).</description>
    <link>https://dev.to/ramthearchitect</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4243545%2F528a6fd8-05e8-42db-b242-b0eca86fc21f.jpg</url>
      <title>DEV Community: Ramanjaneyulu Boya</title>
      <link>https://dev.to/ramthearchitect</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ramthearchitect"/>
    <language>en</language>
    <item>
      <title>Java Memory Management Explained: Heap, Stack, Metaspace and Garbage Collection</title>
      <dc:creator>Ramanjaneyulu Boya</dc:creator>
      <pubDate>Sat, 14 Nov 2026 18:41:08 +0000</pubDate>
      <link>https://dev.to/ramthearchitect/java-memory-management-explained-heap-stack-metaspace-and-garbage-collection-2j38</link>
      <guid>https://dev.to/ramthearchitect/java-memory-management-explained-heap-stack-metaspace-and-garbage-collection-2j38</guid>
      <description>&lt;p&gt;&lt;em&gt;Understanding how the JVM allocates memory, manages objects, performs garbage collection and handles memory-related problems in real-world Java applications.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fftnr8d4u8yb21ny9fra5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fftnr8d4u8yb21ny9fra5.jpg" alt="JVM runtime memory architecture showing heap, stack, metaspace and other memory areas" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Have you ever wondered what happens inside the JVM when you create a Java object?&lt;/p&gt;

&lt;p&gt;Consider a simple statement:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;Customer&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Customer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Ramu"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It looks like a straightforward object creation. However, several things happen behind the scenes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The JVM allocates memory for the object.&lt;/li&gt;
&lt;li&gt;A reference to the object is maintained in the executing thread's stack frame.&lt;/li&gt;
&lt;li&gt;The object is stored in the heap.&lt;/li&gt;
&lt;li&gt;The JVM manages the object's lifecycle.&lt;/li&gt;
&lt;li&gt;When the object is no longer reachable, it becomes eligible for garbage collection.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding these operations is essential for every Java developer, particularly when building high-performance enterprise applications.&lt;/p&gt;

&lt;p&gt;In production environments, improper memory management can lead to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;OutOfMemoryError&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Frequent garbage collection&lt;/li&gt;
&lt;li&gt;Application latency&lt;/li&gt;
&lt;li&gt;Increased CPU utilization&lt;/li&gt;
&lt;li&gt;Memory leaks&lt;/li&gt;
&lt;li&gt;Application crashes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this article, we'll explore Java memory management from the JVM perspective, using Java 21 examples and practical enterprise application scenarios.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Understanding JVM Memory Architecture
&lt;/h2&gt;

&lt;p&gt;The Java Virtual Machine divides memory into different runtime areas to manage application execution efficiently.&lt;/p&gt;

&lt;p&gt;Some memory areas are shared across application threads, while others are created separately for each thread.&lt;/p&gt;

&lt;p&gt;The major JVM runtime memory areas include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Heap&lt;/li&gt;
&lt;li&gt;Java Stack&lt;/li&gt;
&lt;li&gt;Method Area&lt;/li&gt;
&lt;li&gt;Program Counter Register&lt;/li&gt;
&lt;li&gt;Native Method Stack&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Additionally, JVM implementations use native memory areas such as Metaspace and Code Cache.&lt;/p&gt;

&lt;h3&gt;
  
  
  JVM Memory Architecture
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgmevm8jnasynwrahp00m.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgmevm8jnasynwrahp00m.jpg" alt="Java heap memory divided into young generation, Eden, survivor spaces S0 and S1, and old generation" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's understand each component.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.1 Heap Memory
&lt;/h3&gt;

&lt;p&gt;Heap is the primary memory area where Java objects and arrays are allocated.&lt;/p&gt;

&lt;p&gt;Important characteristics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shared across application threads.&lt;/li&gt;
&lt;li&gt;Managed by the garbage collector.&lt;/li&gt;
&lt;li&gt;Stores objects created using &lt;code&gt;new&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Usually the largest JVM memory area.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomerService&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;createCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="nc"&gt;Customer&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
                &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Customer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Ramu"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;Customer&lt;/code&gt; object is allocated on the heap, while the local reference variable &lt;code&gt;customer&lt;/code&gt; resides in the executing method's stack frame.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.2 Java Stack Memory
&lt;/h3&gt;

&lt;p&gt;Each thread has its own Java stack.&lt;/p&gt;

&lt;p&gt;Whenever a method is invoked, the JVM creates a stack frame.&lt;/p&gt;

&lt;p&gt;A stack frame contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Local variables&lt;/li&gt;
&lt;li&gt;Operand stack&lt;/li&gt;
&lt;li&gt;Runtime constant pool reference&lt;/li&gt;
&lt;li&gt;Method execution information&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;processPayment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nc"&gt;Payment&lt;/span&gt; &lt;span class="n"&gt;payment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
            &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Payment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nf"&gt;validatePayment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;amount&lt;/code&gt; is a primitive local variable.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;payment&lt;/code&gt; is a local reference variable.&lt;/li&gt;
&lt;li&gt;The actual &lt;code&gt;Payment&lt;/code&gt; object is allocated on the heap.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each method invocation creates a new stack frame, and the frame is removed when the method completes.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.3 Metaspace
&lt;/h3&gt;

&lt;p&gt;Metaspace stores class metadata required by the JVM.&lt;/p&gt;

&lt;p&gt;It was introduced in Java 8, replacing PermGen.&lt;/p&gt;

&lt;p&gt;Examples of metadata include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Class structure information&lt;/li&gt;
&lt;li&gt;Method metadata&lt;/li&gt;
&lt;li&gt;Runtime constant pool information&lt;/li&gt;
&lt;li&gt;Field information&lt;/li&gt;
&lt;li&gt;Method bytecode-related metadata&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Unlike heap memory, Metaspace uses native memory.&lt;/p&gt;

&lt;p&gt;An important consideration is that excessive class loading or classloader retention can cause Metaspace-related memory problems.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.4 Program Counter Register
&lt;/h3&gt;

&lt;p&gt;Each JVM thread maintains its own Program Counter (PC) register.&lt;/p&gt;

&lt;p&gt;It identifies the JVM instruction currently being executed by that thread.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.5 Native Method Stack
&lt;/h3&gt;

&lt;p&gt;Native Method Stack supports execution of native methods, typically implemented using languages such as C or C++ through JNI.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Understanding Heap Memory Generations
&lt;/h2&gt;

&lt;p&gt;Heap memory is where most Java developers encounter garbage collection concepts.&lt;/p&gt;

&lt;p&gt;In a traditional generational heap model, memory is divided into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Young Generation&lt;/li&gt;
&lt;li&gt;Old Generation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Young Generation is further divided into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Eden Space&lt;/li&gt;
&lt;li&gt;Survivor Space S0&lt;/li&gt;
&lt;li&gt;Survivor Space S1&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff5cpuvc4r1h651d0z4ns.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff5cpuvc4r1h651d0z4ns.jpg" alt="Java garbage collection workflow showing GC roots, reachable objects, unreachable objects, marking and memory reclamation" width="800" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2.1 Eden Space
&lt;/h3&gt;

&lt;p&gt;Most new objects are initially allocated in Eden.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;Customer&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
        &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Customer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Ramu"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The object is typically allocated in Eden when the JVM uses a generational collector.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.2 Survivor Spaces
&lt;/h3&gt;

&lt;p&gt;Survivor spaces are used to hold objects that survive garbage collection in the Young Generation.&lt;/p&gt;

&lt;p&gt;The JVM uses two survivor spaces, conventionally called S0 and S1.&lt;/p&gt;

&lt;p&gt;Objects surviving a minor collection may move between survivor spaces.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.3 Old Generation
&lt;/h3&gt;

&lt;p&gt;Objects that survive multiple young-generation collections may eventually be promoted to the Old Generation.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Long-lived application configuration objects&lt;/li&gt;
&lt;li&gt;Cached reference data&lt;/li&gt;
&lt;li&gt;Shared application-level objects&lt;/li&gt;
&lt;li&gt;Long-running session-related objects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Promotion depends on collector-specific policies and object age and size; it is not simply a fixed rule that every object follows.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. How Garbage Collection Works
&lt;/h2&gt;

&lt;p&gt;Garbage Collection (GC) is the JVM's automatic memory management mechanism.&lt;/p&gt;

&lt;p&gt;Its primary responsibility is to identify objects that are no longer reachable and reclaim their memory.&lt;/p&gt;

&lt;p&gt;An object becomes eligible for garbage collection when it is no longer reachable through the JVM's active reference paths.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MemoryExample&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="nc"&gt;Customer&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
                &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Customer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Ramu"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="n"&gt;customer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After assigning &lt;code&gt;null&lt;/code&gt;, the object may become eligible for garbage collection, assuming no other references exist.&lt;/p&gt;

&lt;p&gt;Remember:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Eligible for garbage collection does not mean immediately garbage collected.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The JVM decides when collection occurs.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.1 Garbage Collection Workflow
&lt;/h3&gt;

&lt;p&gt;A simplified way to understand garbage collection is through these stages:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Identify GC Roots.&lt;/li&gt;
&lt;li&gt;Determine reachable objects.&lt;/li&gt;
&lt;li&gt;Identify unreachable objects.&lt;/li&gt;
&lt;li&gt;Reclaim eligible memory.&lt;/li&gt;
&lt;li&gt;Perform collector-specific compaction or relocation where applicable.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1mq0ttvoyt0kgrsg5tb3.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1mq0ttvoyt0kgrsg5tb3.jpg" alt="Java garbage collection workflow showing GC roots, reachable objects, unreachable objects, marking and memory reclamation" width="800" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Common GC Roots include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Active thread stack references&lt;/li&gt;
&lt;li&gt;Static references&lt;/li&gt;
&lt;li&gt;JNI references&lt;/li&gt;
&lt;li&gt;Other JVM-managed references&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The actual algorithms differ between garbage collectors.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Types of Garbage Collection
&lt;/h2&gt;

&lt;p&gt;Java provides multiple garbage collectors designed for different application requirements.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.1 Serial Garbage Collector
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Uses a single thread for garbage collection.&lt;/li&gt;
&lt;li&gt;Suitable for small applications.&lt;/li&gt;
&lt;li&gt;Can introduce longer pauses as heap size increases.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4.2 Parallel Garbage Collector
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Uses multiple threads for garbage collection.&lt;/li&gt;
&lt;li&gt;Focuses on application throughput.&lt;/li&gt;
&lt;li&gt;Useful for workloads where throughput is more important than minimizing individual pause times.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4.3 G1 Garbage Collector
&lt;/h3&gt;

&lt;p&gt;G1 (Garbage First) is the default garbage collector for typical server-class configurations in modern Java.&lt;/p&gt;

&lt;p&gt;Important characteristics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Divides heap into multiple regions.&lt;/li&gt;
&lt;li&gt;Supports concurrent marking.&lt;/li&gt;
&lt;li&gt;Prioritizes regions with more reclaimable memory.&lt;/li&gt;
&lt;li&gt;Aims to meet configurable pause-time goals.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4.4 Z Garbage Collector (ZGC)
&lt;/h3&gt;

&lt;p&gt;ZGC is designed for low-latency applications.&lt;/p&gt;

&lt;p&gt;Important characteristics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Performs much of its work concurrently.&lt;/li&gt;
&lt;li&gt;Aims to maintain very short GC pauses.&lt;/li&gt;
&lt;li&gt;Supports large heaps.&lt;/li&gt;
&lt;li&gt;Generational ZGC is available in Java 21 as an experimental feature.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Comparison
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Collector&lt;/th&gt;
&lt;th&gt;Primary focus&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Serial GC&lt;/td&gt;
&lt;td&gt;Simplicity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Parallel GC&lt;/td&gt;
&lt;td&gt;Throughput&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;G1 GC&lt;/td&gt;
&lt;td&gt;Balanced performance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ZGC&lt;/td&gt;
&lt;td&gt;Low latency&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The right collector depends on workload characteristics, heap size, latency requirements and available resources.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Understanding Java Memory-Related Errors
&lt;/h2&gt;

&lt;p&gt;Memory problems are common in enterprise applications, especially when applications process large datasets or handle high concurrent traffic.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.1 OutOfMemoryError: Java Heap Space
&lt;/h3&gt;

&lt;p&gt;Occurs when the JVM cannot allocate additional objects in the heap.&lt;/p&gt;

&lt;p&gt;Common causes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unbounded collections&lt;/li&gt;
&lt;li&gt;Excessive object creation&lt;/li&gt;
&lt;li&gt;Memory leaks&lt;/li&gt;
&lt;li&gt;Large data processing without pagination&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ArrayList&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1024&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This continuously allocates memory until the JVM cannot satisfy another allocation.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.2 OutOfMemoryError: Metaspace
&lt;/h3&gt;

&lt;p&gt;Can occur when the JVM cannot allocate additional class metadata.&lt;/p&gt;

&lt;p&gt;Common causes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Excessive dynamic class loading&lt;/li&gt;
&lt;li&gt;Classloader leaks&lt;/li&gt;
&lt;li&gt;Improper application redeployment patterns&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5.3 StackOverflowError
&lt;/h3&gt;

&lt;p&gt;Occurs when a thread's stack is exhausted.&lt;/p&gt;

&lt;p&gt;A common cause is uncontrolled recursion.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;process&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;process&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This method continuously invokes itself without a termination condition.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Memory Leaks in Java Applications
&lt;/h2&gt;

&lt;p&gt;Java has automatic garbage collection, but that does not mean memory leaks are impossible.&lt;/p&gt;

&lt;p&gt;A memory leak happens when objects are no longer needed by the application but remain reachable through references.&lt;/p&gt;

&lt;p&gt;Consider this example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomerCache&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Customer&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="no"&gt;CACHE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ArrayList&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;addCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Customer&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="no"&gt;CACHE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If customers are continuously added and never removed, the static collection retains references to them.&lt;/p&gt;

&lt;p&gt;The garbage collector cannot reclaim these objects while they remain reachable.&lt;/p&gt;

&lt;p&gt;Common causes of memory leaks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Static collections&lt;/li&gt;
&lt;li&gt;Unbounded caches&lt;/li&gt;
&lt;li&gt;Improper ThreadLocal usage&lt;/li&gt;
&lt;li&gt;Event listener references&lt;/li&gt;
&lt;li&gt;Unclosed resources&lt;/li&gt;
&lt;li&gt;Classloader retention&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In production applications, memory leaks can gradually increase heap utilization and eventually cause service failures.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. JVM Memory Monitoring and Troubleshooting
&lt;/h2&gt;

&lt;p&gt;Understanding JVM memory is only the first step.&lt;/p&gt;

&lt;p&gt;Production engineers must also know how to monitor and troubleshoot memory problems.&lt;/p&gt;

&lt;p&gt;Useful JVM tools include:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;jps&lt;/td&gt;
&lt;td&gt;List running Java processes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;jstat&lt;/td&gt;
&lt;td&gt;Monitor JVM statistics&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;jmap&lt;/td&gt;
&lt;td&gt;Inspect heap and generate heap dumps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;jstack&lt;/td&gt;
&lt;td&gt;Capture thread dumps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;jcmd&lt;/td&gt;
&lt;td&gt;Execute diagnostic commands&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Java Flight Recorder&lt;/td&gt;
&lt;td&gt;Profile JVM activity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Java Mission Control&lt;/td&gt;
&lt;td&gt;Analyze JVM recordings&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Example commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jcmd &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;pid&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; GC.heap_info
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jcmd &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;pid&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; GC.class_histogram
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jcmd &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;pid&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; JFR.start &lt;span class="nv"&gt;duration&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;60s &lt;span class="nv"&gt;filename&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;recording.jfr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For garbage collection logging in Java 21:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;-Xlog:gc*:file=gc.log:time,uptime,level,tags
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For heap dump generation when an OutOfMemoryError occurs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;-XX:+HeapDumpOnOutOfMemoryError
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These diagnostics help identify memory consumption patterns, allocation behavior and possible leaks.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. JVM Memory Management in Real-World Banking Applications
&lt;/h2&gt;

&lt;p&gt;Consider a banking application built using Java 21, Spring Boot and microservices.&lt;/p&gt;

&lt;p&gt;The application processes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Customer information&lt;/li&gt;
&lt;li&gt;Account details&lt;/li&gt;
&lt;li&gt;Payment transactions&lt;/li&gt;
&lt;li&gt;Transaction history&lt;/li&gt;
&lt;li&gt;Fraud detection requests&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Imagine a payment service processing thousands of concurrent requests.&lt;/p&gt;

&lt;p&gt;Each request may create multiple temporary objects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Request DTOs&lt;/li&gt;
&lt;li&gt;Validation objects&lt;/li&gt;
&lt;li&gt;Domain objects&lt;/li&gt;
&lt;li&gt;Database entities&lt;/li&gt;
&lt;li&gt;Response DTOs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most temporary objects become eligible for garbage collection after request processing completes.&lt;/p&gt;

&lt;p&gt;However, application-level caches, shared collections and long-lived references may retain objects for much longer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Production considerations
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Set appropriate JVM heap limits.&lt;/li&gt;
&lt;li&gt;Monitor heap utilization and GC pause times.&lt;/li&gt;
&lt;li&gt;Avoid unbounded in-memory collections.&lt;/li&gt;
&lt;li&gt;Use pagination for large database queries.&lt;/li&gt;
&lt;li&gt;Profile object allocation patterns.&lt;/li&gt;
&lt;li&gt;Configure container memory limits carefully.&lt;/li&gt;
&lt;li&gt;Monitor application memory and container memory independently.&lt;/li&gt;
&lt;li&gt;Capture heap dumps when investigating memory leaks.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For applications running on Kubernetes or OpenShift, remember that the JVM operates within container memory constraints.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;-XX:MaxRAMPercentage=75.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This allows the JVM to calculate its maximum heap based on the available memory it detects, subject to the JVM and container configuration.&lt;/p&gt;

&lt;p&gt;The remaining container memory must also accommodate Metaspace, thread stacks, direct buffers, code cache and other native allocations.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. JVM Memory Tuning in Java 21
&lt;/h2&gt;

&lt;p&gt;Some useful JVM options include:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;JVM option&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-Xms&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Initial heap size&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-Xmx&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Maximum heap size&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-Xss&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Thread stack size&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-XX:+UseG1GC&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Enable G1 GC&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-XX:+UseZGC&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Enable ZGC&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-XX:MaxMetaspaceSize&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Set Metaspace limit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-XX:MaxRAMPercentage&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Set maximum heap percentage relative to detected RAM&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;java \
-Xms2g \
-Xmx4g \
-XX:+UseG1GC \
-Xlog:gc*:file=gc.log \
-jar banking-service.jar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Important: JVM tuning should be based on actual workload measurements rather than blindly applying configuration values.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Best Practices for Java Memory Management
&lt;/h2&gt;

&lt;p&gt;Here are some practical guidelines for enterprise Java applications:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Avoid unnecessary object creation in performance-critical paths.&lt;/li&gt;
&lt;li&gt;Prefer bounded caches over unbounded collections.&lt;/li&gt;
&lt;li&gt;Use pagination for large database operations.&lt;/li&gt;
&lt;li&gt;Close resources using try-with-resources.&lt;/li&gt;
&lt;li&gt;Avoid retaining unnecessary references.&lt;/li&gt;
&lt;li&gt;Monitor garbage collection regularly.&lt;/li&gt;
&lt;li&gt;Understand container memory limits.&lt;/li&gt;
&lt;li&gt;Use heap dumps and profiling tools during troubleshooting.&lt;/li&gt;
&lt;li&gt;Select garbage collectors based on application requirements.&lt;/li&gt;
&lt;li&gt;Measure performance before and after tuning.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Java memory management is much more than understanding Heap, Stack and Garbage Collection.&lt;/p&gt;

&lt;p&gt;It is about understanding how the JVM allocates objects, manages their lifecycle, identifies unreachable references and reclaims memory efficiently.&lt;/p&gt;

&lt;p&gt;For enterprise applications, especially banking and financial systems, effective memory management directly influences application stability, performance, scalability and reliability.&lt;/p&gt;

&lt;p&gt;As Java developers and architects, understanding JVM internals helps us build applications that are not only functional but also production-ready.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keep learning. Keep building. Keep architecting.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;— Ram The Architect (RTA)&lt;/p&gt;




&lt;h3&gt;
  
  
  Further Reading and Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Java 21 Documentation: &lt;a href="https://docs.oracle.com/en/java/javase/21/" rel="noopener noreferrer"&gt;https://docs.oracle.com/en/java/javase/21/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Java Virtual Machine Specification: &lt;a href="https://docs.oracle.com/javase/specs/jvms/se21/html/" rel="noopener noreferrer"&gt;https://docs.oracle.com/javase/specs/jvms/se21/html/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Java Garbage Collection Documentation: &lt;a href="https://docs.oracle.com/en/java/javase/21/gctuning/" rel="noopener noreferrer"&gt;https://docs.oracle.com/en/java/javase/21/gctuning/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/Ramu-fsd" rel="noopener noreferrer"&gt;https://github.com/Ramu-fsd&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Discussion
&lt;/h3&gt;

&lt;p&gt;What garbage collector do you primarily use in your production Java applications — G1 GC, Parallel GC or ZGC?&lt;/p&gt;

&lt;p&gt;Have you encountered an OutOfMemoryError or a memory leak in a production environment? Share your experience in the comments.&lt;/p&gt;

</description>
      <category>java</category>
      <category>jvm</category>
      <category>programming</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
