Workaround taken from bug #4724038 to release the memory mapped byte buffer. Little quote from SUN: This is highly inadvisable, to put it mildly. It is exceedingly dangerous to forcibly unmap a mapped byte buffer that's
(final Object buffer)
| 681 | * all kind of evil stuff |
| 682 | */ |
| 683 | private void clean(final Object buffer) throws Exception { |
| 684 | AccessController.doPrivileged(new PrivilegedAction<Object>() { |
| 685 | public Object run() { |
| 686 | try { |
| 687 | Method getCleanerMethod = buffer.getClass().getMethod( |
| 688 | "cleaner", new Class[0]); |
| 689 | getCleanerMethod.setAccessible(true); |
| 690 | sun.misc.Cleaner cleaner = (sun.misc.Cleaner) getCleanerMethod |
| 691 | .invoke(buffer, new Object[0]); |
| 692 | cleaner.clean(); |
| 693 | } catch (Exception e) { |
| 694 | e.printStackTrace(); |
| 695 | } |
| 696 | return null; |
| 697 | } |
| 698 | }); |
| 699 | } |
| 700 | |
| 701 | /** |
| 702 | * Gets MAT-file header |