Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Your JVM flags stop at the native boundary

Java teams put real effort into the JVM. Heap sizes get argued about in pull requests, and someone usually makes sure GC logs end up somewhere searchable. That work assumes the JVM is where the interesting things happen. Once a service leans on native code, through JNI or by shelling out to a binary, part of its behaviour lives somewhere those settings can't reach. Memory the heap dump can't see…

The article discusses issues that arise when Java Virtual Machine (JVM) flags are applied to native code. When a Java service utilizes native libraries through JNI or by executing external binaries, certain JVM settings become ineffective in monitoring memory usage. This can be problematic as the memory allocated by the native libraries may exceed the JVM's allocated heap size, leading to Out Of Memory (OOM) errors.

Tools such as Native Memory Tracking (NMT) are designed to track memory allocations made by the JVM itself, but they do not account for memory allocated by third-party native code. This discrepancy can cause memory usage to appear normal within the JVM while the overall process size continues to grow.

Container environments often limit the resources available to Java processes through settings like -XX:MaxRAMPercentage, which allocates a portion of the container's memory for various purposes including native libraries. When a service receives multiple requests simultaneously, it can quickly exhaust the allocated memory, leading to performance issues.

Additionally, the glibc allocator, which is used by the Linux kernel for memory management, may create multiple memory arenas that can cause the RSS (Resident Set Size) of the process to increase without being reclaimed by the OS. Mitigation strategies include reducing the number of arenas or switching to an alternative allocator like jemalloc, but these changes typically require adjustments at the container level.

One common scenario involves third-party native libraries that extract their .so files from the JAR file into a temporary directory at runtime. This behavior can cause issues when the container has a read-only root filesystem or when the /tmp directory is set to be non-executable. In these cases, the JVM may fail to load the native libraries, resulting in an UnsatisfiedLinkError.

The solution typically involves configuring the system property to point to a writable directory where the libraries can be extracted. Each of these native libraries has its own system property that must be set for this configuration.

When deploying applications that use multiple native libraries, it's important to note that each library can only be loaded by a single classloader. Attempting to load the same library from a different classloader results in an UnsatisfiedLinkError. This is particularly relevant for application servers that redeploy without restarting the JVM, as the old classloader retains the loaded libraries.

To avoid this issue, libraries should be moved to a shared parent classloader, ensuring they are deployed and upgraded with the application rather than independently.

Shelling out to external binaries also introduces potential issues. ProcessBuilder in Java manages subprocesses, but if a child process consumes more output than the OS pipe buffer can handle, this can lead to a deadlock where the Java process waits for the child to write, while the child waits for the Java process to read. This scenario is exacerbated when the child process writes large amounts of data, potentially resulting in a deadlock that can affect the overall system performance.

A recommended workaround is to avoid using pipes altogether, consolidating stderr with stdout and redirecting both to a log file. This approach prevents the Java process from getting stuck waiting indefinitely for data that may never arrive.

Malformed inputs to subprocesses can also cause unexpected behavior. A converter within a process might enter an infinite loop, consuming CPU resources and holding both Java threads and OS processes, leading to resource exhaustion. To mitigate this, setting a timeout for waiting on the process is a practical solution. If the timeout is reached, the parent process can terminate its descendants, preventing the zombies from accumulating.

Tools that spawn helper processes should be designed to handle these scenarios appropriately. Additionally, when dealing with fonts, native renderers rely on the fontconfig library to manage font resources. In containerized environments where fontconfig might not be installed, Java applications could encounter incorrect rendering behavior, leading to unexpected text layout issues.

Explicitly installing fonts in the Dockerfile can help ensure consistent behavior across different deployment environments.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

How to Build a Command Palette in React (Cmd+K)

Your app has dozens of actions spread across menus. Power users want one shortcut that gets them anywhere. A react command palette fixes that. Press Cmd+K, type two letters, press Enter.

  • Define component behavior with Cmd+K (macOS) and Ctrl+K (other) shortcuts
  • Render modal dialog with focused search field, filter commands on typing
  • Handle arrow key navigation, active row movement, Enter to run command

How to Research Shopify App Competitors (Pricing, Ratings & Reviews) in 5 Minutes

If you build (or plan to build) a Shopify app, the first question is always the same: who am I up against, what do they charge, and how happy are their users?

  • Shopify App Store provides ratings, reviews, pricing, and "Built for Shopify" badge for competitors
  • Top apps in "upsell" search have similar pricing ($9–$19/month) and high ratings (4.8–5.0)
  • Review count, not ranking, correlates with success; top app has 6,960+ reviews

Kubernetes Default-Deny NetworkPolicy East-West Isolation & PostgreSQL FORCE RLS Hardening

Production application breaches frequently chain two adjacent boundary failures : unrestricted east-west Kubernetes pod networking (letting a compromised edge container reach internal PostgreSQL ports…

  • Enforce zero-trust network microsegmentation in Kubernetes CNI layer
  • Implement PostgreSQL FORCE ROW LEVEL SECURITY for tenant isolation
  • Ten deterministic AppSec controls verified with Python 3 verifier

What changed in AWS Transform and what I expect to see at re:Invent

I'm already at re:Invent, having coffee before the first sessions. I started writing this text on the first flight and kept working on it between one flight and another.

  • AWS Transform enables collaboration on code updates with other AWS accounts
  • Integration with AWS Health identifies affected repositories for code changes
  • .NET developers can update projects to .NET 11, VB.NET support moves out of preview

More from Monday, 30 November 2026 →