开发者

Is it possible to get flat (unboxed) structures in Java?

I want to create a structure with several arrays inside and possibly other structures. Is it possibl开发者_如何学Ce To have "flat" memory layout for this? I.e. One piece of memory witout pointers?


I don't think so. Outside of using one big array for everything and writing your own code to represent objects as arrays of, say, bytes, which is a bad idea. In Java, everything but primitives is a reference automatically; you can't work directly with arrays or objects.

Why do you need a flat memory chunk? If you're worried about memory allocation issues, consider some sort of object pool.


The closest you can get in memory or functionality is an array of primitives, such as byte[]. This is how MemoryImageSource and BufferedImage work to relatively efficiently store and blit images.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜