File Streaming in Java

后端 未结 3 1265
我在风中等你
我在风中等你 2020-12-15 00:32

I\'m currently developing 3D graphics application using JOGL (Java OpenGL binding). In brief, I have a huge landscape binary file. Due to its size, I have t

3条回答
  •  抹茶落季
    2020-12-15 00:59

    No, the data is not buffered. A MappedByteBuffer references the data using a pointer. In other words, the data is not copied, it is simply mapped into physical memory. See the API docs if you haven't already.

    A memory-mapped file is a segment of virtual memory which has been assigned a direct byte-for-byte correlation with some portion of a file or file-like resource. This resource is typically a file that is physically present on-disk, but can also be a device, shared memory object, or other resource that the operating system can reference through a file descriptor. Once present, this correlation between the file and the memory space permits applications to treat the mapped portion as if it were primary memory.

    Source: Wikipedia

    If you are going to be reading data quite frequently, it is a good idea to at least cache some of it.

提交回复
热议问题