▲ 6 r/optimization
Débutant avec Java 25 (Panama) et solvers C : comment éviter les baisses de performances dues aux copies mémoire ?
Hello everyone,
I’m completely new to the topics of native memory and interoperability.
I’m trying to create a Java library (using the Adapter pattern) to connect several mathematical solvers together. I’ve found that most solvers on the market have C APIs (e.g., HiGHS).
I decided to use Project Panama (Java 22’s FFM API) for communication between Java and C. However, I understand that if I pass standard Java arrays to my C solver, the JVM will copy this data into memory. Since solvers handle a lot of data, I’m worried that the time spent copying will completely ruin performance.
So I wanted to know:
- Is this impact from copying really that significant in practice?
- I’ve heard about creating the data directly in “Off-Heap” (using MemorySegment) (I might be mistaken about how to use it). Is this the only good solution, and is it very complex to implement for a beginner?
Thank you very much for your patience and advice!
u/pomplyne — 4 days ago