“Java uses too much memory.” Still true? 10,000 threads used to cost ~10GB. Today with virtual threads: ~50–100MB. Same language. Different reality. Here’s what actually changed: • Modern GC (ZGC, Shenandoah) → low pause, concurrent cleanup • Virtual Threads (Project Loom) → massive drop in memory per thread • Compact Object Headers → smaller objects at scale • Container-aware JVM → no more over-allocation • CDS → shared memory across services Most “Java memory problems” aren’t JVM problems. They’re: Unbounded caches Poor object design Holding references too long Example: Unbounded cache = memory leak Bounded cache (Caffeine) = stable footprint Java didn’t stay the same. Many assumptions did. If your service uses 2GB RAM, profile your code before blaming the JVM. What’s the biggest memory issue you’ve seen in production? #Java #JVM #Backend #SoftwareEngineering #Performance #MemoryOptimization #SystemDesign #DistributedSystems #Scalability #Microservices #CloudComputing #Kubernetes #DevOps #Programming #Coding #Tech #Developers #GarbageCollection #LowLatency #Concurrency #Multithreading #ProjectLoom #ZGC #Shenandoah #GraalVM #FinOps #CloudCost #Optimization
Java Memory Usage: What's Changed and What's Not
More Relevant Posts
-
Go has no threads. Yet it handles 10x more concurrent requests than Java. Here is why that should change how you think about concurrency. When thousands of requests hit a server simultaneously, the biggest bottleneck is always the thread. Traditional languages like Java create one OS thread per request. Threads are heavy, kernel managed, and expensive to context switch. Go solved this differently with Goroutines. → A Goroutine's stack is dynamic. It only grows when it actually needs to, not upfront → Creating a Goroutine involves zero system calls. The kernel has no idea it exists → Context switching happens entirely in user space. No kernel involvement whatsoever → The Go scheduler handles everything. OS threads only see what Go exposes to them This is powered by the GMP model: → G: Goroutines, can run in the millions → M: Machine, the actual OS threads, just a handful → P: Processor, the logical CPU that schedules G onto M Millions of Goroutines multiplex across just a few OS threads. When a Goroutine blocks, Go detaches that thread, spins up work elsewhere, and keeps everything moving. The program never stalls. A Goroutine starts at just 2KB because Go's runtime manages memory dynamically instead of fixed provisioning like the OS does. This is not a language feature. It is an architectural decision. Minimize kernel involvement. Maximize work in user space. Let the runtime do what the OS was doing badly. That is the real reason Go scales the way it does. What architecture decision in your stack has had the biggest impact on performance? #GoLang #SystemDesign #BackendEngineering #Concurrency #BuildingInPublic #TechFounders #SoftwareArchitecture #Engineering #Programming #DevOps
To view or add a comment, sign in
-
⚙️ Want to take your Java skills to the next level? Start understanding what happens inside the JVM. Advanced JVM Internals & Performance Tuning is where good developers become great. 💡 When you understand: ✔ Garbage Collection (GC) ✔ Memory Management (Heap, Stack, Metaspace) ✔ JVM Architecture & Execution Engine You can build applications that are not just functional—but fast, efficient, and scalable 🚀 Performance tuning isn’t just optimization… it’s about writing smarter code and making the JVM work for you. 💭 Are you monitoring your JVM performance or just hoping it works fine? #Java #JVM #PerformanceTuning #JavaDeveloper #GarbageCollection #SoftwareDevelopment #Programming #BackendDevelopment #TechSkills #Developers #Coding #ITJobs
To view or add a comment, sign in
-
-
Ever wondered what happens after you write Java code? 🤔 👉 .java → .class → JVM → Execution That’s where JVM Architecture comes in! ⚙️ Class Loader 🧠 Memory Areas 🚀 Execution Engine ♻️ Garbage Collector All working together to run your code smoothly 💯 Drop a 🔥 if this helped you! #Java #JVMArchitecture #CodingJourney #ProgrammerLife #SoftwareEngineer #LearnProgramming #TechExplained #CodeDaily #Developers #JavaLearning
To view or add a comment, sign in
-
-
Java Virtual Threads: simplifying concurrency without switching paradigms For a long time, scalable concurrency in Java meant choosing between: ▪️ thread pools with careful tuning ▪️ asynchronous code (CompletableFuture) ▪️ reactive programming All of these approaches work, but they introduce additional complexity into the codebase. Virtual threads (Project Loom) take a different direction: keep the blocking programming model, but remove the scalability limitations of OS threads. What changes with virtual threads Virtual threads are lightweight and managed by the JVM. Instead of mapping one thread to one OS thread, the JVM schedules many virtual threads onto a smaller pool of carrier threads. This allows: ▪️ creating a large number of concurrent tasks ▪️ writing code in a familiar, sequential style ▪️ avoiding callback chains and reactive pipelines Where they fit well ▪️ Virtual threads are a good fit for: ▪️ I/O-bound services ▪️ systems with many concurrent requests ▪️ service-to-service communication ▪️ database and external API calls In these scenarios, most of the time is spent waiting, not computing. Virtual threads allow the system to scale without blocking OS threads. Limitations and trade-offs They do not improve CPU-bound workloads. If tasks are heavy on computation, the number of cores remains the limiting factor. They also require attention to blocking operations: ▪️ poorly implemented blocking (e.g. native calls) can pin carrier threads ▪️ libraries not designed for this model may reduce the benefits Adoption also depends on ecosystem readiness and team familiarity. Why this matters Virtual threads make it possible to build highly concurrent systems without introducing a different programming model. For many backend services, this can reduce the need for reactive or heavily asynchronous code, while keeping the system scalable. The key question is not whether virtual threads replace existing approaches, but where they simplify the system without introducing new risks. Have you tried virtual threads in real systems, and where do you see the biggest impact? #java #concurrency #backend #softwareengineering #loom #microservices
To view or add a comment, sign in
-
The Java Exception Hierarchy: Know your tools. 🛠️ In Java, not all errors are created equal. Understanding the difference between Checked, Unchecked, and Errors is the "Aha!" moment for many developers. Checked Exceptions: Your "Expect the unexpected" scenarios (e.g., IOException). The compiler forces you to handle these. Unchecked Exceptions (Runtime): These are usually "Programmer Oopsies" (e.g., NullPointerException). They represent bugs that should be fixed, not just caught. Errors: The "System is on fire" scenario (e.g., OutOfMemoryError). Don't try to catch these; just let the ship sink gracefully. Mastering this hierarchy is the difference between writing "working" code and "production-ready" code. #JavaDevelopment #Coding #TechEducation #JVM #SoftwareArchitecture
To view or add a comment, sign in
-
🚀 Most developers learn Java syntax... But very few understand how memory management works behind the scenes. That’s where JVM concepts make all the difference 👇 ☕ 5 JVM Concepts Every Java Developer Should Know 1️⃣ Heap Memory ↳ Stores objects during runtime 👉 Important for memory usage 2️⃣ Stack Memory ↳ Stores method calls & local variables 👉 Faster execution handling 3️⃣ Garbage Collection ↳ Automatically removes unused objects 👉 Better memory management 4️⃣ JIT Compiler ↳ Converts bytecode into native machine code 👉 Improves performance 5️⃣ Class Loader ↳ Loads classes dynamically at runtime 👉 Core of Java execution 💡 Here’s the truth: Great Java developers don’t just write code... They understand how Java runs internally. #Java #JVM #Programming #SoftwareEngineer #Coding #Developers #Tech #BackendDevelopment #SpringBoot #JavaDeveloper
To view or add a comment, sign in
-
-
One of the most important topics in Java development is understanding the Collections Framework. Choosing the right collection can directly impact application performance, scalability, and code maintainability. Here’s a simple rule I follow: ✔ Use List when order matters ✔ Use Set when uniqueness is required ✔ Use Map for key-value storage ✔ Use Queue for processing tasks in sequence A good developer doesn’t just write code — they choose the right data structure for the right problem. 🚀 #Java #CollectionsFramework #JavaDeveloper #Programming #BackendDevelopment #SoftwareEngineering #DataStructures #Coding #Developers #Tech #LearnJava #CodeQuality
To view or add a comment, sign in
-
-
🚀 Day 2 of My DSA Journey in Java Today, I learned how a Java program actually works behind the scenes 👇 🔹 **Java Program Execution Flow:** 1. **User Code (.java):** The code we write is not directly understood by the machine. 2. **Compiler:** Converts the code into *bytecode* (.class file), which is platform-independent. 3. **JVM (Java Virtual Machine):** Translates bytecode into machine-readable instructions and executes it. 🔹 **Key Terminology:** • **JRE (Java Runtime Environment):** Provides the environment (JVM + libraries) to run Java programs. • **JDK (Java Development Kit):** Includes JRE + development tools like compiler and debugger. 📌 **Hierarchy to remember:** JDK > JRE > JVM Understanding this foundation makes Java truly powerful and platform-independent 💻✨ #DSA #Java #LearningJourney #Programming #Coding
To view or add a comment, sign in
-
How JVM Works in Java ☕🚀 Ever wondered what happens after we write and run a Java program? The JVM (Java Virtual Machine) makes it possible for Java to be platform independent. From compiling source code into bytecode, loading classes, managing memory through Heap and Stack, executing code with the JIT Compiler, to automatic Garbage Collection — JVM handles it all behind the scenes. Understanding JVM internals helps developers write better, optimized, and scalable applications. Excited to keep exploring Java fundamentals one concept at a time! #Java #JVM #JavaDeveloper #Programming #SoftwareEngineering #BackendDevelopment #Tech #LearningJourney
To view or add a comment, sign in
-
-
🚀 Multithreading in Java: 7 Concepts Every Backend Engineer Should Actually Understand Most developers can spin up a thread. Few can debug one at 2 AM in production. Here’s what separates the two 👇 1️⃣ Thread vs Runnable vs Callable Runnable → returns nothing Callable → returns a Future Thread → execution unit 💡 Prefer Callable + ExecutorService over new Thread() 2️⃣ volatile ≠ synchronized volatile → guarantees visibility, not atomicity count++? Still broken. ✅ Use AtomicInteger. 3️⃣ synchronized vs ReentrantLock synchronized → simpler, but limited ReentrantLock gives: tryLock() timed waits fairness interruptibility 🎯 Choose based on control needs. 4️⃣ ExecutorService > manual thread creation Thread creation is expensive. Pool them. FixedThreadPool → predictable load CachedThreadPool → short-lived bursts ScheduledThreadPool → delayed / periodic work ⚠️ Avoid unbounded pools in production. 5️⃣ CompletableFuture is your async Swiss Army knife thenApply() thenCompose() thenCombine() Handle errors with exceptionally() 🙅♂️ Never call .get() on the main request thread. 6️⃣ Concurrent Collections Matter HashMap + concurrent writes = 💥 Use: ConcurrentHashMap CopyOnWriteArrayList BlockingQueue 🎯 Choose based on your read/write ratio. 7️⃣ Deadlock Needs 4 Conditions Mutual exclusion Hold-and-wait No preemption Circular wait 💡 Break any one → prevent deadlock Lock ordering is often the simplest fix. 💡 The real lesson: Concurrency bugs don’t show up in your IDE. They show up under load… in production… at the worst time. Master the fundamentals before reaching for reactive frameworks. 🧩 What’s the nastiest multithreading bug you’ve debugged in production? #Java #Multithreading #Concurrency #BackendEngineering #SystemDesign #JavaDeveloper #SoftwareEngineering #DistributedSystems #Scalability #Performance #CodingInterview #TechInterview #JVM #AsyncProgramming #Microservices 🚀
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development