{"id":29969,"date":"2023-03-07T09:31:19","date_gmt":"2023-03-07T14:31:19","guid":{"rendered":"https:\/\/www.eginnovations.com\/blog\/?p=29969"},"modified":"2023-06-28T04:00:10","modified_gmt":"2023-06-28T08:00:10","slug":"7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate","status":"publish","type":"post","link":"https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/","title":{"rendered":"7 Myths of Java Memory Leaks: What SREs Need to Know and Communicate"},"content":{"rendered":"<div class=\"inner_content\">\n<p>Consider the scenario &#8211; You are an SRE (Site Reliability Engineer) joining a team to take charge of their Java applications. It has been reported that a Java application is very flaky in terms of memory issues and probably has a Java memory leak. You have a large cluster with many <a href=\"https:\/\/www.eginnovations.com\/supported-technologies\/jvm-monitoring\">hundreds of JVMs (Java Virtual Machines) to monitor<\/a>. Each time a memory incident happens, the conversations with the Application Development (AppDev) teams have gone on the lines of &#8220;not reproducible&#8221; or &#8220;works fine on my machine&#8221;.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-30254\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/works-fine-on-machine-eg.webp\" alt=\"\" width=\"750\" height=\"296\" \/><\/p>\n<p>Management recently moved to a cloud-based infrastructure and feel that the cloud and JVM will take care of all issues. How do you approach such a scenario? What myths are you likely to have to debunk? How do you justify the budget for the use of tools, automation, and changes in work practice to detect and resolve Java memory issues?<\/p>\n<p>Here are some myths to be on the lookout for when it comes to <a href=\"https:\/\/www.eginnovations.com\/supported-technologies\/java-application-monitoring\">Java memory leaks<\/a>.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Myth_1_Java_has_automatic_memory_management_so_there_is_no_need_to_worry_about_memory_leaks\"><\/span>Myth #1: Java has automatic memory management, so there is no need to worry about memory leaks.<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"alignright \"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30256\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/memory-leaks.webp\" alt=\"\" width=\"280\" height=\"251\" \/><\/div>\n<p style=\"margin-bottom: 15px;\"><strong>Reality:<\/strong> Memory leaks can still occur due to buggy application code that:<\/p>\n<ul>\n<li>Creates objects but does not de-reference them<\/li>\n<li>Holds on to static objects in HashMap or HashSet<\/li>\n<li>Does not close resources like JDBC (Java Database connectivity) connections, ResultSet, and Statement objects, file handles and sockets<\/li>\n<li>Keeps references to objects in ThreadLocal without cleaning them up<\/li>\n<\/ul>\n<p style=\"margin-bottom: 15px;\"><img decoding=\"async\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2020\/09\/hand-symbol.png\" alt=\"\" width=\"32px\" \/> <strong>Actions:<\/strong><\/p>\n<div class=\"alignright \">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30256\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/benchmarks-eg.webp\" alt=\"\" width=\"280\" height=\"251\" srcset=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/benchmarks-eg.webp 280w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/benchmarks-eg-140x126.webp 140w\" sizes=\"auto, (max-width: 280px) 100vw, 280px\" \/><\/p>\n<div class=\"img_caption\" style=\"width: 280px; margin-bottom: 0px!important; margin-top: -25px!important;\">Figure 1: Set up memory usage benchmarks and chaos engineering tests on production-like environments<\/div>\n<\/div>\n<p>#1: Work with your upper management team to get budgets for production-like environments. Getting a replica environment up and running is usually simple on the cloud provided you have the right <a href=\"https:\/\/www.eginnovations.com\/blog\/what-is-iac-infrastructure-as-code\/\">IaC (Infrastructure as Code)<\/a> tools set up. A good replica environment will allow you to run realistic loads and get memory benchmarks. It has become industry best practice to set up memory usage benchmarks and <a href=\"https:\/\/www.eginnovations.com\/blog\/what-is-chaos-engineering\/\">chaos engineering<\/a> tests on production-like environments.<\/p>\n<p>#2: Use automatic memory leak detection and <a href=\"https:\/\/www.eginnovations.com\/supported-technologies\/jvm-monitoring\">JVM monitoring tools<\/a> that give you early and proactive alerting on memory leaks. You can also use open-source tools (such as JVisualVM and MAT) but doing so across a Java cluster with hundreds of JVMs at non-regular hours (i.e., 2 am) will be cumbersome. Using heap dumps after the fact is reactive and too late in the game.<\/p>\n<p>#3: Work with your AppDev team on <a href=\"https:\/\/www.eginnovations.com\/blog\/what-is-chaos-engineering\/\">chaos engineering<\/a> and game days to simulate edge cases. Cloud services such as the <a href=\"https:\/\/aws.amazon.com\/fis\/\" target=\"blank\" rel=\"noopener\">Amazon AWS Fault Injector Service<\/a> are now available to assist automating and integrating chaos workflows into standard development workflows. We have listed a few tools you may leverage to \u201ckick the tyres\u201d on your systems and applications, here: <a href=\"https:\/\/www.eginnovations.com\/blog\/it-infrastructure-management\/\">IT Infrastructure Management \u2013 Tools and Strategies (eginnovations.com).<\/a> Formalizing chaos and \u201cresilience testing\u201d methodologies into development workflows can assist ISVs (Independent Software Vendors) and partners meet the criteria for formal partnership programs, compliance with major cloud providers frameworks such as the <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/architecture\/framework\/resiliency\/chaos-engineering\" target=\"blank\" rel=\"noopener\">\u201cMicrosoft Well-Architected Framework for Azure\u201d<\/a> and can help those delivering services on cloud infrastructure gain credibility and confidence with customers and attract new business.<\/p>\n<p><a href=\"https:\/\/www.eginnovations.com\/demo\/java-monitoring\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-30186\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/java-apm-demo.webp\" alt=\"\" width=\"850\" height=\"160\" srcset=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/java-apm-demo.webp 850w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/java-apm-demo-300x56.webp 300w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/java-apm-demo-768x145.webp 768w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/java-apm-demo-800x151.webp 800w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/java-apm-demo-310x58.webp 310w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/java-apm-demo-140x26.webp 140w\" sizes=\"auto, (max-width: 850px) 100vw, 850px\" \/><\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Myth_2_Memory_leaks_are_only_a_concern_for_applications_with_a_high_level_of_traffic_or_usage\"><\/span>Myth #2: Memory leaks are only a concern for applications with a high level of traffic or usage<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"margin-bottom: 15px;\"><strong>Reality:<\/strong> Memory leaks can also occur in applications with low levels of traffic or usage and can gradually grow over time.<\/p>\n<p>With many businesses now running large numbers of microservices the cumulative effect of numerous inferior services and applications can collectively result in significant issues.<\/p>\n<p style=\"margin-bottom: 15px;\"><img decoding=\"async\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2020\/09\/hand-symbol.png\" alt=\"\" width=\"32px\" \/> <strong>Actions:<\/strong><\/p>\n<div class=\"alignright\" style=\"height: 300px;\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30256\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/soak-test-1.webp\" alt=\"\" width=\"280\" height=\"251\" \/><\/p>\n<div class=\"img_caption\" style=\"width: 280px; margin-bottom: 0px!important; margin-top: -15px!important;\">Figure 2: Soak tests can simulate long-term usage and uncover memory leak<\/div>\n<\/div>\n<p>#1 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Soak_testing\" target=\"blank\" rel=\"noopener\">Soak tests<\/a> can simulate long-term usage and uncover memory leaks. Running soak tests should be considered standard best practice. Some issues such as memory leaks do not become apparent until the system has been running for a while.<\/p>\n<p>Often QA teams run load tests or stress tests but may have neglected to run soak tests (also known as endurance testing). While load testing is primarily concerned with performance assessment, and stress testing is concerned with system stability under extreme conditions, soak testing is concerned with reliability over a longer period of time. SREs often face the need to clarify the remit of test methodologies within an organization, articles such as <a href=\"https:\/\/www.blazemeter.com\/blog\/stress-testing-vs-soak-testing-vs-spike-testing\" target=\"blank\" rel=\"noopener\">Stress Testing, Soak Testing and Spike Testing Best Practices<\/a> and <a href=\"https:\/\/www.blazemeter.com\/blog\/performance-testing-vs-load-testing-vs-stress-testing\" target=\"blank\" rel=\"noopener\">Performance Testing vs. Load Testing vs. Stress Testing<\/a> may assist conversations.<\/p>\n<p>Top tip: If costs are a concern, you can run a low traffic scenario on spot instances or a medium instance on the cloud. Calibrate the load suitably to match the Java memory settings &#8211; Xmx and Xms, etc.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Myth_3_Our_code_is_A_grade_quality_We_can_never_have_memory_leaks\"><\/span>Myth #3: Our code is A+ grade quality. We can never have memory leaks<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"margin-bottom: 15px;\"><strong>Reality:<\/strong> You could have written the best code, but your dependency libraries could have memory leaks.<\/p>\n<p style=\"margin-bottom: 15px;\"><img decoding=\"async\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2020\/09\/hand-symbol.png\" alt=\"\" width=\"32px\" \/> <strong>Actions:<\/strong><\/p>\n<div class=\"alignright \">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30256\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/tick-eg-img.webp\" alt=\"\" width=\"280\" height=\"251\" \/><\/p>\n<div class=\"img_caption\" style=\"width: 280px; margin-bottom: 0px!important; margin-top: -25px!important;\">Figure 3: Make an inventory of dependent libraries for your application and test them for memory leaks.<\/div>\n<\/div>\n<p style=\"margin-bottom: 15px;\">Get an inventory of dependent libraries for your application and test them for memory leaks.<\/p>\n<p>#1: Make a full inventory of application dependencies. APM (Application Performance Monitoring) tools can help uncover hidden dependencies.<\/p>\n<p>#2: Check if you have upgraded to the latest version and that you have processes in place to upgrade ongoing. This can be extremely important to ensure that your applications and services are secure and fully supported. Organizations that failed to schedule an upgrade from libraries with dependencies such as TLS 1.0 to TLS 1.2 faced security vulnerabilities beyond the issues of vendors such as <a href=\"https:\/\/learn.microsoft.com\/en-us\/lifecycle\/announcements\/transport-layer-security-1x-disablement\" target=\"blank\" rel=\"noopener\">Microsoft withdrawing support<\/a> for applications dependent on legacy versions.<\/p>\n<p>#3: Run soak tests that exercise the functionality of dependency libraries.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Myth_4_If_we_throw_more_memory_at_the_application_it_should_take_care_of_our_problems\"><\/span>Myth #4: If we throw more memory at the application, it should take care of our problems<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"margin-bottom: 15px;\"><strong>Reality:<\/strong> Throwing more memory is not the answer to a memory leak.<\/p>\n<p>Memory leaks are like a bottomless pit &#8211; the more you throw in, the more it wants. You will eventually hit the upper limit of memory. You cannot predict when the application will hit the upper limit \u2013 when it does, your production service will suffer.<\/p>\n<p>For example, you may have a memory leak in an important report. As more users access it concurrently, the system will eventually crash with an OutOfMemoryError.<\/p>\n<p>If leveraging cloud infrastructure such as Google GCP (Google Cloud Platform), Microsoft Azure or Amazon AWS, resource based and PAYG (Pay As You Go) pricing means that unnecessary resources you use to mitigate memory leaks will impact your business\u2019 profits and \/ or consume budget you could be spending on nicer things.<\/p>\n<p style=\"margin-bottom: 15px;\"><img decoding=\"async\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2020\/09\/hand-symbol.png\" alt=\"\" width=\"32px\" \/> <strong>Actions:<\/strong><\/p>\n<div class=\"alignright \">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30151\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/memory-leak.webp\" alt=\"\" width=\"280\" height=\"251\" srcset=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/memory-leak.webp 280w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/memory-leak-140x126.webp 140w\" sizes=\"auto, (max-width: 280px) 100vw, 280px\" \/><\/p>\n<div class=\"img_caption\" style=\"width: 280px; margin-bottom: 0px!important; margin-top: -25px!important;\">Figure 4: Throwing more memory isn&#8217;t the answer to a memory leak<\/div>\n<\/div>\n<p>#1 Use automatic memory leak detection and <a href=\"https:\/\/www.eginnovations.com\/supported-technologies\/jvm-monitoring\">JVM monitoring tools<\/a> that pinpoint leak suspects. These tools do the heavy lifting of sifting through detailed logs and monitoring metrics, using object histograms and heap dumps to identify the leak suspect.<\/p>\n<p>#2 Understand the types of coding errors that cause memory leaks. There are plenty of good articles covering common coding errors and flaws, see: <a href=\"https:\/\/www.eginnovations.com\/blog\/6-tips-fast-java-applications\/\">How to make Java run faster &#8211; 6 Tips | eG Innovations<\/a> and <a href=\"https:\/\/www.baeldung.com\/java-memory-leaks\" target=\"blank\" rel=\"noopener\">Understanding Memory Leaks in Java | Baeldung.<\/a> Use tools with code-level visibility to identify leaks and prove coding errors to developers, see what is possible in: <a href=\"https:\/\/www.eginnovations.com\/blog\/java-code-level-visibility\/\">Java Code Level Visibility | eG Innovations.<\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Myth_5_-_If_your_application_is_the_highest_memory_consumer_it_has_a_memory_leak\"><\/span>Myth #5: \u2013 If your application is the highest memory consumer, it has a memory leak!<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"margin-bottom: 15px;\"><strong>Reality:<\/strong> Sometimes, applications could genuinely need a lot of memory, and this could cause a spike in heap usage. This does not necessarily mean that there is a memory leak.<\/p>\n<p style=\"margin-bottom: 15px;\"><img decoding=\"async\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2020\/09\/hand-symbol.png\" alt=\"\" width=\"32px\" \/> <strong>Actions:<\/strong><\/p>\n<div class=\"alignright \">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30152\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/guessing-game.webp\" alt=\"\" width=\"280\" height=\"251\" srcset=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/guessing-game.webp 280w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/guessing-game-140x126.webp 140w\" sizes=\"auto, (max-width: 280px) 100vw, 280px\" \/><\/p>\n<div class=\"img_caption\" style=\"width: 280px;\">Figure 5: Don&#8217;t play a guessing game with memory leaks, use monitoring tools<\/div>\n<\/div>\n<p>#1 Don&#8217;t play a guessing game with memory leaks, use monitoring tools. Examining the trend of your Java heap will help you determine if there is a memory leak. The application may naturally use a certain amount of memory, and the garbage collector will periodically reclaim memory at certain thresholds. You should see a rise and fall of heap usage with garbage collection.<\/p>\n<p>#2 Evaluate those monitoring tools thoroughly. Good automatic memory leak detection and JVM monitoring tools use automatic baselining patterns and <a href=\"https:\/\/www.eginnovations.com\/product\/capabilities\/aiops-monitoring\">AIOps (Artificial Intelligence for Operations) \/ machine learning techniques<\/a> to distinguish between inadequate or insufficient memory resource allocation vs a memory leak. Eliminate the guessing game.<\/p>\n<p>#3 Question high memory usage or runtimes of third-party applications. There is a huge amount of flaky code out there that whilst it does not actually leak memory, simply is not optimized. Understanding types of coding flaws and optimizations that impact applications can help you recognize the symptoms if they impact your IT operations team. If an application\u2019s resource usage seems excessive raise questions with the vendor \/ supplier.<\/p>\n<p>Good APM tools can often help you reverse engineer third-party applications and gather data to support your suspicions to help raise requests for improvements from third-party vendors.<\/p>\n<p><a href=\"https:\/\/www.eginnovations.com\/white-paper\/java-application-performance\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-28407\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2022\/11\/java-whitepaper-banner.webp\" alt=\"\" width=\"800\" height=\"200\" srcset=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2022\/11\/java-whitepaper-banner.webp 800w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2022\/11\/java-whitepaper-banner-300x75.webp 300w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2022\/11\/java-whitepaper-banner-768x192.webp 768w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2022\/11\/java-whitepaper-banner-310x78.webp 310w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2022\/11\/java-whitepaper-banner-140x35.webp 140w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Myth_6_Restarting_the_Application_or_Server_will_Fix_Memory_Leaks\"><\/span>Myth #6: Restarting the Application or Server will Fix Memory Leaks<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><strong>Reality:<\/strong> It is quite common for ITOps teams to put in quick fixes such as restarting applications or servers. Restarting the application itself will not necessarily release any memory inappropriately allocated and often only frees that memory allocated correctly that could be cleaned up by regular garbage collection, the freeing of that memory might buy you a bit of time, but the problem will reoccur.<\/p>\n<p>Rebooting application servers or physical servers will reset the memory but long-term, any issues leading to memory leaks will reoccur, often more frequently. Needing to reboot servers regularly is an indication of application issues and that your applications may be consuming resources unnecessarily and exposed to performance issues and slowdowns. Ignoring indicators of application issues is unwise.<\/p>\n<p style=\"margin-bottom: 15px;\"><img decoding=\"async\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2020\/09\/hand-symbol.png\" alt=\"\" width=\"32px\" \/> <strong>Actions:<\/strong><\/p>\n<div class=\"alignright\" style=\"height: 300px;\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30153\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/Turning-off.webp\" alt=\"\" width=\"280\" height=\"251\" srcset=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/Turning-off.webp 280w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/Turning-off-140x126.webp 140w\" sizes=\"auto, (max-width: 280px) 100vw, 280px\" \/><\/p>\n<div class=\"img_caption\" style=\"width: 280px;\">Figure 6: Turning it off and on again doesn\u2019t stop the source of a memory leak<\/div>\n<\/div>\n<p>#1 Proactively identify frequent server reboots and consider monitoring Server Uptime beyond Server Availability. The article, <a href=\"https:\/\/www.eginnovations.com\/blog\/server-uptime-monitoring\/\">What is Server Uptime Monitoring? (eginnovations.com)<\/a> helps explain the differences. eG Enterprise\u2019s extensive auditing capabilities ensure that you will be able to trace who or what triggered reboots see: <a href=\"https:\/\/www.eginnovations.com\/blog\/auditing-capabilities-in-it-monitoring-tools-for-security-and-compliance\/\/\">Auditing Capabilities in IT Monitoring Tools | eG Innovations.<\/a> The fix history capabilities also provide administrators with the capacity to record and document the reasons and history when a decision to reboot is taken.<\/p>\n<p>#2 Train and educate staff to avoid bad-practices and quick fixes if possible. Put in workflows and tooling to ensure that if steps like server reboots are used (to get users working again quickly), those incidents can be retrospectively analyzed to address the true root-cause later.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Myth_7_Memory_Leaks_Only_Happen_in_Older_Versions_of_Java\"><\/span>Myth #7: Memory Leaks Only Happen in Older Versions of Java<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><strong>Reality:<\/strong> Memory leaks can happen in any version of Java, including the latest version. In fact, new features and improvements in Java can sometimes introduce new sources of memory leaks. For example, there were memory leaks associated with the C2 JIT Compiler in Java 11.0.16 that <a href=\"https:\/\/docs.cloudbees.com\/docs\/cloudbees-ci-kb\/latest\/client-and-managed-masters\/memory-leak-c2-jit-compiler-java-11.0.16\">impacted applications such as Jenkins.<\/a> <em>Note: Errors in compilers can be a source of memory leaks even when the original source code has no errors.<\/em><\/p>\n<p style=\"margin-bottom: 15px;\"><img decoding=\"async\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2020\/09\/hand-symbol.png\" alt=\"\" width=\"32px\" \/> <strong>Actions:<\/strong><\/p>\n<div class=\"alignright \">\n<p><img loading=\"lazy\" decoding=\"async\" width=\"280\" height=\"251\" class=\"size-full wp-image-30154\" style=\"margin-top: -15px; width: 260px;\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/upto-date.webp\" alt=\"\" srcset=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/upto-date.webp 280w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/upto-date-140x126.webp 140w\" sizes=\"auto, (max-width: 280px) 100vw, 280px\" \/><\/p>\n<div class=\"img_caption\" style=\"width: 260px; margin-bottom: 0px!important; margin-top: -30px!important;\">Figure 7: Keep up to date with changes and known sources of memory leaks<\/div>\n<\/div>\n<p>#1 SREs should be aware of Java version and compiler changes and make sure they are familiar with any known new sources of memory leaks.<\/p>\n<p>#2 When new versions of languages such as Java and compiler tools are released it is best practice to avoid any other changes so regressive behavior can be easily identified a linked to the version changes. Avoid infrastructure, operating system, and application code changes where possible \u2013 this can be challenging if relying on public Cloud type infrastructure.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Takeaway_Thought\"><\/span>Takeaway Thought<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>As an SRE it is important for you to work with non-technical stakeholders and educate them about the realities of JVM and memory management. Raising awareness and addressing misconceptions can help you prove your value to a budget and long-term help you justify budgets and resources such as hardware, staffing and good monitoring and diagnostic tools.<\/p>\n<p><a href=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/SREs-topology-view.jpg\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-30188\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/SREs-topology.webp\" alt=\"\" \/><\/a><\/p>\n<div class=\"img_caption\">Figure 8: SREs need the ability to visualize memory anomalies in a topology view to pinpoint which Java services to troubleshoot<\/div>\n<p>If you set up the right tools to accurately diagnose and fix memory leaks, you can minimize Mean Time To Resolution (MTTR) and avoid putting business SLAs (Service Level Agreements) at risk.<\/p>\n<p><a href=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/SRE-Dashboard-view.jpg\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-30191\" src=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/SRE-Dashboard.webp\" alt=\"\" width=\"750\" height=\"395\" srcset=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/SRE-Dashboard.webp 750w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/SRE-Dashboard-300x158.webp 300w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/SRE-Dashboard-310x163.webp 310w, https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/SRE-Dashboard-140x74.webp 140w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/a><\/p>\n<div class=\"img_caption\">Figure 9: Unified dashboards showing various Java memory related metrics will help an SRE in early detection of a memory leak and act proactively<\/div>\n<div class=\"containers mb-4\" style=\"clear:both\">\n \t<div class=\"fixed-free-trial-div mb-3\" id=\"fixedsectioninfo_blog_btn\">\n \t\n \t<style>.containers_hide_row,.all_blogs_bottom{\n \tdisplay:none;\n   \n}\t<\/style>\n                <div class=\"box-style container row pt-4 pb-4  animatedParent animateOnce\" data-sequence=\"100\" style=\"border-bottom: 1px solid #ddd;border-top: 1px solid #ddd;background: #4b4b4b;padding: 15px 15px 0 15px;border-radius: 12px;\">\n                \n                <div class=\"text-center animated fadeIn go\"> \n                <p class=\"text-center mb-4\" style=\"    color: #fff;\">\n\neG Enterprise is an Observability solution for Modern IT. Monitor digital workspaces, <br\/>web applications, SaaS services, cloud and containers from a single pane of glass.\n<\/p>\n                <\/div>\n                    <div class=\"text-center pb-1 animated fadeIn go\" data-id=\"8\">\n                        <a class=\"border-btnhead-eg\"  href=\"https:\/\/www.eginnovations.com\/it-monitoring\/free-trial\"> <span style=\"font-family: GraphikMedium!important;color: #fff;\">Free Trial<\/span><\/a>\n                        <a href=\"https:\/\/www.eginnovations.com\/product\/application-performance-monitoring\" class=\" border-btnhead-eg\" style=\"width:230px;   \"> <svg width=\"24\" height=\"24\" style=\"margin-top:-3px\" version=\"1.1\" id=\"Layer_1\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 26.5 26.5\" style=\"enable-background:new 0 0 26.5 26.5;\" xml:space=\"preserve\">\n<style type=\"text\/css\">\n\t.st2{fill:#fff !important;stroke:#fff !important;stroke-miterlimit:10;}\n\t\n\t\t.border-btnhead:hover .st2 {\n  fill: #ffffff !important;\n  stroke: #ffffff;\n}\n<\/style>\n<g>\n\t<g>\n\t\t<path class=\"st2\" d=\"M13.3,25.8c-6.9,0-12.5-5.6-12.5-12.5S6.4,0.8,13.3,0.8s12.5,5.6,12.5,12.5S20.2,25.8,13.3,25.8z M13.3,1.8\n\t\t\tC6.9,1.8,1.8,6.9,1.8,13.3S7,24.8,13.3,24.8s11.5-5.2,11.5-11.5S19.6,1.8,13.3,1.8z M11.2,18.1c-0.2,0-0.4-0.1-0.6-0.2\n\t\t\tc-0.3-0.2-0.6-0.6-0.6-1V9.7c0-0.4,0.2-0.8,0.6-1c0.3-0.2,0.8-0.2,1.2,0l6.2,3.6c0.3,0.2,0.6,0.6,0.6,1s-0.2,0.8-0.6,1l-6.2,3.6\n\t\t\tC11.6,18,11.4,18.1,11.2,18.1z\"\/>\n\t<\/g>\n<\/g>\n<\/svg> <span style=\"font-family: GraphikMedium!important;color: #fff;\">&nbsp;See the platform<\/span><\/a>\n                    <\/div>\n                <\/div>\n                \n                 <\/div>\n            <\/div>\n<h2><span class=\"ez-toc-section\" id=\"Related_Information\"><\/span>Related Information<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"margin-bottom: 15px;\">If you enjoyed this article or found it useful to use to explain the role of an SRE, you might like to explore these:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.eginnovations.com\/blog\/what-is-garbage-collection-java\/\/\">What is Java Garbage Collection<\/a><\/li>\n<li>An overview of eG Enterprise\u2019s Java support <a href=\"https:\/\/www.eginnovations.com\/supported-technologies\/java-application-monitoring\">Java Monitoring &#8211; Java Application Troubleshooting Tool (eginnovations.com),<\/a> links to .NET, PHP and Node.js coverage are accessible via this link too<\/li>\n<li><a href=\"https:\/\/www.eginnovations.com\/blog\/top-10-java-performance-problems\/\">Top Java Performance Problems &amp; How to Fix them<\/a><\/li>\n<li><a href=\"https:\/\/www.eginnovations.com\/demo\/java-monitoring\">How to Simplify Java Monitoring and Get Code-Level Visibility (eginnovations.com)<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Consider the scenario &#8211; You are an SRE (Site Reliability Engineer) joining a team to take charge of their Java applications. It has been reported that a Java application is very flaky in terms of memory issues and probably has a Java memory leak. You have a large cluster with many hundreds of JVMs (Java [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":30176,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"_lmt_disableupdate":"no","_lmt_disable":"","footnotes":""},"categories":[371,27],"tags":[1352,1155,2040,173,2039,1220,2020,176,1363,1214,1245,502,1497,2021,578,2018,2019],"class_list":["post-29969","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-application-performance-monitoring-apm","category-java-monitoring","tag-apm-monitoring-tool","tag-devops-and-sres","tag-eclipse","tag-java-application-monitoring","tag-java-memory","tag-java-memory-leak","tag-java-memory-leak-detection","tag-java-monitoring","tag-java-out-of-memory","tag-jconsole","tag-jvisualvm","tag-jvm","tag-jvm-garbage-collectors","tag-jvm-heap","tag-jvm-monitoring","tag-mat","tag-memory-leak"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java Memory Leak: 7 Myths that SREs Need to Know<\/title>\n<meta name=\"description\" content=\"Applications slow down and become unresponsive if a Java memory leak happens. Learn 7 myths that SREs must tackle to ensure great performance.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Memory Leak: 7 Myths that SREs Need to Know\" \/>\n<meta property=\"og:description\" content=\"Applications slow down and become unresponsive if a Java memory leak happens. Learn 7 myths that SREs must tackle to ensure great performance.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/\" \/>\n<meta property=\"og:site_name\" content=\"eG Innovations\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/eGInnovations\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-07T14:31:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-28T08:00:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/02\/Java-MYth-Social-Banner-Image.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Arun Aravamudhan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/02\/Java-MYth-Social-Banner-Image.jpg\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/x.com\/perfclarity\" \/>\n<meta name=\"twitter:site\" content=\"@eginnovations\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Arun Aravamudhan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Memory Leak: 7 Myths that SREs Need to Know","description":"Applications slow down and become unresponsive if a Java memory leak happens. Learn 7 myths that SREs must tackle to ensure great performance.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/","og_locale":"en_US","og_type":"article","og_title":"Java Memory Leak: 7 Myths that SREs Need to Know","og_description":"Applications slow down and become unresponsive if a Java memory leak happens. Learn 7 myths that SREs must tackle to ensure great performance.","og_url":"https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/","og_site_name":"eG Innovations","article_publisher":"https:\/\/www.facebook.com\/eGInnovations","article_published_time":"2023-03-07T14:31:19+00:00","article_modified_time":"2023-06-28T08:00:10+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/02\/Java-MYth-Social-Banner-Image.jpg","type":"image\/jpeg"}],"author":"Arun Aravamudhan","twitter_card":"summary_large_image","twitter_image":"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/02\/Java-MYth-Social-Banner-Image.jpg","twitter_creator":"@https:\/\/x.com\/perfclarity","twitter_site":"@eginnovations","twitter_misc":{"Written by":"Arun Aravamudhan","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/#article","isPartOf":{"@id":"https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/"},"author":{"name":"Arun Aravamudhan","@id":"https:\/\/www.eginnovations.com\/blog\/#\/schema\/person\/d788cb81df96a940429c3f5a3b294a6a"},"headline":"7 Myths of Java Memory Leaks: What SREs Need to Know and Communicate","datePublished":"2023-03-07T14:31:19+00:00","dateModified":"2023-06-28T08:00:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/"},"wordCount":2109,"publisher":{"@id":"https:\/\/www.eginnovations.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/#primaryimage"},"thumbnailUrl":"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/7-myth-java-Thumbnail.jpg","keywords":["APM monitoring tool","devops and SREs","eclipse","Java Application Monitoring","java memory","java memory leak","java memory leak detection","Java Monitoring","Java out of memory","jconsole","JVisualVM","JVM","JVM Garbage Collectors","JVM heap","JVM Monitoring","MAT","memory leak"],"articleSection":["Application Performance Monitoring (APM)","Java Monitoring"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/","url":"https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/","name":"Java Memory Leak: 7 Myths that SREs Need to Know","isPartOf":{"@id":"https:\/\/www.eginnovations.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/#primaryimage"},"image":{"@id":"https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/#primaryimage"},"thumbnailUrl":"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/7-myth-java-Thumbnail.jpg","datePublished":"2023-03-07T14:31:19+00:00","dateModified":"2023-06-28T08:00:10+00:00","description":"Applications slow down and become unresponsive if a Java memory leak happens. Learn 7 myths that SREs must tackle to ensure great performance.","breadcrumb":{"@id":"https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/#primaryimage","url":"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/7-myth-java-Thumbnail.jpg","contentUrl":"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2023\/03\/7-myth-java-Thumbnail.jpg","width":362,"height":235},{"@type":"BreadcrumbList","@id":"https:\/\/www.eginnovations.com\/blog\/7-myths-of-java-memory-leaks-what-sres-need-to-know-and-communicate\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.eginnovations.com\/blog\/"},{"@type":"ListItem","position":2,"name":"7 Myths of Java Memory Leaks: What SREs Need to Know and Communicate"}]},{"@type":"WebSite","@id":"https:\/\/www.eginnovations.com\/blog\/#website","url":"https:\/\/www.eginnovations.com\/blog\/","name":"eG Innovations","description":"IT Performance Monitoring Insights","publisher":{"@id":"https:\/\/www.eginnovations.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.eginnovations.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.eginnovations.com\/blog\/#organization","name":"eG Innovations","alternateName":"eg innovations","url":"https:\/\/www.eginnovations.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.eginnovations.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2014\/07\/eg-logo-dark-gray1_new.jpg","contentUrl":"https:\/\/www.eginnovations.com\/blog\/wp-content\/uploads\/2014\/07\/eg-logo-dark-gray1_new.jpg","width":362,"height":235,"caption":"eG Innovations"},"image":{"@id":"https:\/\/www.eginnovations.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/eGInnovations","https:\/\/x.com\/eginnovations"]},{"@type":"Person","@id":"https:\/\/www.eginnovations.com\/blog\/#\/schema\/person\/d788cb81df96a940429c3f5a3b294a6a","name":"Arun Aravamudhan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.eginnovations.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/7ff42334d908fb4060880a4487331e4a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7ff42334d908fb4060880a4487331e4a?s=96&d=mm&r=g","caption":"Arun Aravamudhan"},"sameAs":["https:\/\/www.linkedin.com\/in\/arun-aravamudhan\/","https:\/\/x.com\/https:\/\/x.com\/perfclarity"],"url":"https:\/\/www.eginnovations.com\/blog\/author\/arun-aravamudhan\/"}]}},"modified_by":"eG Innovations","_links":{"self":[{"href":"https:\/\/www.eginnovations.com\/blog\/wp-json\/wp\/v2\/posts\/29969","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.eginnovations.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.eginnovations.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.eginnovations.com\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.eginnovations.com\/blog\/wp-json\/wp\/v2\/comments?post=29969"}],"version-history":[{"count":0,"href":"https:\/\/www.eginnovations.com\/blog\/wp-json\/wp\/v2\/posts\/29969\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.eginnovations.com\/blog\/wp-json\/wp\/v2\/media\/30176"}],"wp:attachment":[{"href":"https:\/\/www.eginnovations.com\/blog\/wp-json\/wp\/v2\/media?parent=29969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.eginnovations.com\/blog\/wp-json\/wp\/v2\/categories?post=29969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.eginnovations.com\/blog\/wp-json\/wp\/v2\/tags?post=29969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}