Questions tagged [mappedbytebuffer]

A direct byte buffer whose content is a memory-mapped region of a file.

A direct byte buffer whose content is a memory-mapped region of a file.

Part of java.nio package from version 1.4

Docs: https://docs.oracle.com/javase/7/docs/api/java/nio/MappedByteBuffer.html

61 questions
1
vote
2 answers

Out of Memory Error: Java Heap space

I'm trying to read a file using mapped byte buffer and am getting an OutOfMemoryError:JavaHeapSpace at the line buffer.position(position);.. I don't understand what's wrong in the code.. What could be the reason for the error? private void…
Arun
  • 21
  • 1
  • 6
1
vote
1 answer

Renaming file after it has been opened as a RandomAccessFile and mapped as a MappedByteBuffer

I am trying to rename a file that I used as a RandomAccessFile before. When I try to rename the file I get an error on the renameTo call. When I use the Windows application Process Monitor I see that there was no rename call. How is it possible…
Bart
  • 97
  • 5
1
vote
1 answer

32-bit JVM maximum memory size on 64-bit Windows not as large as expected

I've been having a tough time memory mapping a 550MB file. I understand that 32-bit JVM can allocate a maximum memory size of around 1.4G, so I need to map a large file by parts. However, this is a 550MB file but I still cannot map it all into…
Fenwick
  • 1,061
  • 2
  • 15
  • 28
1
vote
1 answer

MappedByteBuffer to bitmap?

I have a MappedByteBuffer with a portion of it containing the bytes of a PNG file. I want to call: BitmapFactory.decodeByteArray(byte[] data, int offset, int length); Do I have to move the portion of the MappedByteBuffer into a byte[] or is there…
Fra
  • 393
  • 7
  • 19
1
vote
1 answer

mmap() vs Java MappedByteBuffer performance?

I have been developing a C++ project from existing Java code. I have the following C++ code and Java code reading from the same test file, which consists of millions of integers. C++: int * arr = new int[len]; //len is larger than the largest…
Fenwick
  • 1,061
  • 2
  • 15
  • 28
1
vote
2 answers

MappedByteBuffer clear cached Pages

I've got a problem with MappedByteBuffer specially how it works internally. The way I understand it the caching is done completely by the Operating System. So if I read from the file (using MappedByteBuffer) the OS will read whole pages from the…
Karamba
  • 138
  • 2
  • 15
1
vote
1 answer

MappedByteBuffer - mapping of pages into physical memory

As far as I see it, the MappedByteBuffer, after a call to FileChannel.map "maps" file content into memory, but not necessarily loading the whole file in. So, if I start reading e.g. at pos(0), a page might be actually loaded from disk at that time…
Bober02
  • 15,034
  • 31
  • 92
  • 178
0
votes
0 answers

Converting a file to netty ByteBuf

I need to convert a large file (2GB) to netty byteBuf. I am using the following code its working File file = (File) fw; FileInputStream fileInputStream = new FileInputStream(file); FileChannel fileChannel =…
dev_101
  • 321
  • 4
  • 14
0
votes
1 answer

Java19 Foreign Memory - Read Varint from a MemorySegment

I need to read from a large memory mapped file and as we know, ByteBuffer suffer from many limitations, like the 2GB size limit and developers are unable to deallocate a MemoryMapped file. I was investigating MemorySegment which aims to solve all…
0
votes
1 answer

Java mmap MappedByteBuffer

Let’s say I’ve mapped a memory region [0, 1000] and now I have MappedByteBuffer. Can I read and write to this buffer from multiple threads at the same time without locking, assuming that each thread accesses different part of the buffer for exp. T1…
0
votes
0 answers

Passing a Large CSV or Excel file containing float values to a Java MappedByteBuffer without having to separate values one by one or line by line

I am trying to pass a Large CSV with float values to a MappedByteBuffer. I want it to be read as float values instead of text and dont want to have to parse it character by character and remove commas (delimiters). I want to process it as a 2D array…
Awais
  • 1
  • 1
0
votes
0 answers

Fast non-blocking read/writes using MappedByteBuffer?

I am processing messages from a vendor as a stream of data and want to store msgSeqNum locally in a local file. Reason: They send msgSeqNum to uniquely identify each message. And they provide a 'sync-and-stream' functionality to stream messages on…
saurabh.in
  • 389
  • 3
  • 13
0
votes
0 answers

Self manageable Memory mapped ByteBuffers

My application has to buffer short living but quite big arrays of data. And there might be many big arrays at the same time in the memory. I carrying files through the business logic in not ok. I have to manage these files and take care of…
Denys Kurochkin
  • 1,360
  • 1
  • 18
  • 34
0
votes
0 answers

How to create MappedByteBuffer from the ByteArrayInputStream?

I have an API which returns me the content in form of ByteArrayInputStream basically which is a video content. Now for streaming it looks MappedByteBuffer seems best fit. So how to convert this ByteArrayInputStream to an instance of…
suchit
  • 57
  • 9
0
votes
0 answers

TFLite Android: Model file will not load. startOffset and declaredLength problems

I'm having issues with loading a TFLite model using the MappedByteBuffer method from the Tensorflow-for-poets-2 TFLite tutorial. private MappedByteBuffer loadModelFile(Activity activity,String MODEL_FILE) throws IOException { AssetFileDescriptor…
Andrew
  • 183
  • 1
  • 8