tag:blogger.com,1999:blog-8712770457197348465.post3414294525159321995..comments2024-03-29T00:43:22.798-07:00Comments on Javarevisited: Why use Memory Mapped File or MapppedByteBuffer in Java? Examplejavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-8712770457197348465.post-35187916345199258182018-04-02T03:39:27.936-07:002018-04-02T03:39:27.936-07:00Hello,
Thanks for your article...
Is there any wa...Hello, <br />Thanks for your article...<br />Is there any way to get the address of memory mapped file or address of Buffers ?<br />Now i'm using "ffmpeg" in android project and it wants an address of input and output file to process , so I wanna the input and output to be buffers ... <br />Do you know how can it be done?<br />Thanksحسینhttps://www.blogger.com/profile/00982925771482093390noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-84320677734344396632015-05-11T02:21:57.655-07:002015-05-11T02:21:57.655-07:00I’d just like to add that I’ve created a library c...I’d just like to add that I’ve created a library called MappedBus (http://github.com/caplogic/mappedbus) which enable several Java processes (JVMs) to use a memory mapped file for IPC. For this it makes use of Unsafe, CAS and volatile read/writes. The full explanation of how it’s done is at the github page if you’re interested.MikaelJhttp://github.com/caplogic/mappedbusnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-79954525747623140532015-05-09T14:07:56.071-07:002015-05-09T14:07:56.071-07:00Rahul,
To use memory mapped files for IPC feel fre...Rahul,<br />To use memory mapped files for IPC feel free to check out my library, MappedBus, (http://github.com/caplogic/mappedbus). It supports having multiple processes (JVMs) adding records to the same memory mapped file as well as multiple processes reading from the file.MikaelJhttp://github.com/caplogic/mappedbusnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-20735924872807454562015-01-21T05:35:30.278-08:002015-01-21T05:35:30.278-08:00Hi Javin,
can u please show how memorymapped file...Hi Javin,<br /><br />can u please show how memorymapped files can be used for inter-process communicationRahul Kulshreshthahttps://www.blogger.com/profile/18029365719154056479noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-28661584038803983662014-02-12T17:19:36.372-08:002014-02-12T17:19:36.372-08:00Javin,
Thanks for a great article. While looking a...Javin,<br />Thanks for a great article. While looking at the MappedByteBuffer code, I found that its only DirectByteBuffer backed. So, how so you think its required to be GCed?<br /><br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-80663462097023654682013-10-22T22:10:30.553-07:002013-10-22T22:10:30.553-07:00Few more things to remember while using Memory Map...Few more things to remember while using Memory Mapped File for high performance application :<br /><br />1) Prefer Direct Byte buffer over Non Direct Buffer<br />2) Don't call MappedByteBuffer.force() method to often, this method is meant to force operating system to write content of memory into disk, So if you call force() method each time you write into memory mapped file, you will not see Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-1259312001633287262013-10-01T02:55:38.290-07:002013-10-01T02:55:38.290-07:00Hello Sir, What is difference between direct and n...Hello Sir, What is difference between direct and non direct byte buffer in Java? Levinoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-51596358320197779672013-10-01T02:54:47.421-07:002013-10-01T02:54:47.421-07:00How big memory mapped file can be in Java? I read ...How big memory mapped file can be in Java? I read that it can only be 2GB because ByteBuffer, which is often used as MappedByteBuffer uses integer as index, which means only 2GB? What to do to map a file which is larger than 2GB in Java?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-19759358583297552172013-07-19T22:11:03.881-07:002013-07-19T22:11:03.881-07:00What happens when there is a io exception from the...What happens when there is a io exception from the disk? Does the java program get a chance to recover or does the process crash?CKhttps://www.blogger.com/profile/05815494028419700127noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-6439226705900134962012-05-23T02:42:57.536-07:002012-05-23T02:42:57.536-07:00@Anonymous, you are right, MappedByteBuffer and fi...@Anonymous, you are right, MappedByteBuffer and file mapping remains valid until buffer is garbage collected. sun.misc.Cleaner is probably the only option available to clear memory mapped file. If I come across any other method to unmap or clean contents of MappedByteBuffer I will let you know.shambhuhttp://en.wikipedia.org/wiki/Memory-mapped_filenoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-13162177360485126702012-01-25T02:54:22.777-08:002012-01-25T02:54:22.777-08:00Hi Javin, but isn't it true that you cannot un...Hi Javin, but isn't it true that you cannot unmap a memory mapped file, which can only be done if the garbage collector collects your buffer? In that case isn't memory mapped file a bit useless?<br /><br />I have read on Peters blog where he used the sun.misc.Cleaner file to clean up the memory mapped file, is this the correct approach? I say this because there is no update on the SUN Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-90562564602805644742012-01-15T07:13:28.224-08:002012-01-15T07:13:28.224-08:00Java memory mapped I/O is quite nice!
But I would ...Java memory mapped I/O is quite nice!<br />But I would like to point out that the count number you stated (count = 1010241024) is not 10 MB it's actually 963 MB.<br />Just don't be suprised when the file grows bigger and bigger ;)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-85905220759186774162012-01-13T07:02:16.347-08:002012-01-13T07:02:16.347-08:00It even useful for exchanging data which is update...It even useful for exchanging data which is updated very quickly as well. esp. if its data you need to persist anyway.Peter Lawreyhttps://www.blogger.com/profile/17982030676088168612noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-21168587792647737432012-01-06T18:54:28.946-08:002012-01-06T18:54:28.946-08:00Thanks Peter.Indeed key advantage is file sharing ...Thanks Peter.Indeed key advantage is file sharing and shared memory which allows two process to read from a memory mapped, very useful to keep static or product data on high frequency trading system.Javin @ how to run Java Programhttp://javarevisited.blogspot.com/2011/11/run-java-program-from-command-prompt.htmlnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-35543239049741672012-01-06T07:24:44.105-08:002012-01-06T07:24:44.105-08:00Nice article. I would add that changes don't ...Nice article. I would add that changes don't need to be flushed to disk. If you change a memory value and immediately die (e.g. triggering a SIGSEGV) the change is still saved to disk (Provided your OS doesn't die)<br /><br />Another advantages is that the file can be shared, giving you shared memory between processes and can be more than 10x lower latency than using a Socket over Peter Lawreyhttps://www.blogger.com/profile/17982030676088168612noreply@blogger.com