3

Why does Java need to copy heap memory from(to) direct memory when involving IO system call?

Some articles say that's because of the GC, but I don't understand it clearly. And if it's truly because of the GC, do other languages have this problem, such as Go or Python?

trincot
  • 317,000
  • 35
  • 244
  • 286
lookno
  • 41
  • 1
  • 1
    Where have you seen that claim? And what do you mean by "direct memory"? – Joachim Sauer Sep 12 '19 at 09:38
  • Maybe [this article](https://developer.ibm.com/articles/j-zerocopy/) will help you understand the topic better. – Joachim Sauer Sep 12 '19 at 09:50
  • I'm not JVM guy but isn't it because for years there was no general concept of objects' *pinning* in JVM? So typically their data must be copied to be safely used by the native code, not aware of compacting GC? I think Shenandoah does it better. [Here's a nice summary](https://shipilev.net/jvm/anatomy-quarks/9-jni-critical-gclocker/). – Konrad Kokosa Sep 12 '19 at 10:09

0 Answers0