trying to store java objects in contiguous memory

后端 未结 4 1458
情歌与酒
情歌与酒 2021-02-08 18:33

I am trying to implement a cache-like collection of objects. The purpose is to have fast access to these objects through locality in memory since I\'ll likely be reading multip

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-08 19:28

    Have you written this code yet in Java? And if so, have you profiled it? I would argue that you probably don't need to worry about the objects being in contiguous memory - the JVM is better at memory management than you are in a garbage collected environment.

    If you're really concerned about performance, maybe Java isn't the right tool for the job, but my gut instinct is to tell you that you're worrying about optimization too early, and that a Java version of your code, working with non-contiguous memory, will probably suit your needs.

提交回复
热议问题