English 中文(简体)
字节缓冲器能否作为长寿命静态物体使用?
原标题:Can ByteBuffers be used as long living static objects?
  • 时间:2012-05-25 04:51:40
  •  标签:
  • java

我需要将ByteBuffer 某些对象作为静态字段存放在我的班级中。 是否有人担心这些物体会储存多久, 或者我应该按需创建这些物体? 我经常需要查看这些物体 。

问题回答

缓冲器不是安全的线条。 所以如果它是一个多线应用程序, 您需要特别小心。 这里也有类似的讨论 :

< a href=>ByteBoffer作为各类中的静态最后字段

如果是这样的话,我的建议是动态地创建它,因为它会帮助您只为操作所需的数据分配内存。 如果您将内存集中起来, 而将要读取的数据少于分配, 那么将会分配不必要的内存 。

希望这能帮到你





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签