<div dir="ltr"><p>Hello everyone, hope you're doing well!</p><p>I have a question, and I’m hoping this is the right place to ask. If it's not, I’d appreciate it if someone could point me to the correct mailing list.</p><p>Our team is heavily using JNI C++ code for computations that involve frequent object allocations and deallocations. To optimize these memory operations, we tested using <code>jemalloc</code> as a replacement for <code>glibc</code>, and observed huge improvements in performance metrics.</p><p>We're currently using <code>LD_PRELOAD</code> to load the <code>jemalloc</code> library when launching the JVM, so that all memory allocation and deallocation requests are handled by <code>jemalloc</code>. However, I'm wondering if this approach could lead to any unexpected issues, since it would also take the JVM's memory allocation requests as well.</p><p>From what I understand, heap allocations in the JVM don't use <code>malloc</code> directly, as they rely on optimized assembly code or the JVM's internal memory management system. Some folks on the internet have mentioned that the JVM might have a custom <code>malloc</code> implementation designed specifically for its use, preloading jemalloc may cause symbol conflicts. However, I haven't been able to find any code supporting that hypothesis.</p><p><b><u>My question is: is it safe to use <code>LD_PRELOAD</code> to load a custom <code>malloc</code> library, like <code>jemalloc</code>, when running the JVM, at least with OpenJDK?</u></b></p><p><br><br>Thank you in advance.<br><br>Dooyong Kim</p></div>