Is there a way to bind a byte array in java, so it never moves / compacts?
I am working on an application that should have zero GCs at runtime, and I want to use primitive byte arrays that are bound to a memory display area. Is there any way to do this or hack my way to it?
You can use ByteBuffer / allocateDirect (). This creates a byte buffer that is in the "c" space and does not use heap, so it will not move and can be used effectively with JNI calls.
? ?
, :
EDIT :
, . I.e, - :
/** Byte arrays that you absolutely have to keep. */ public class KeepForever { /** Note that I make no claims about thread safety in this simple example. */ public static byte [] keepMe = new byte[100]; }; // Much later in example code .... /** This should always succeed. No worries about garbage collection. */ public void setMe(int index, byte newByte) { // Admittedly, this defeats several principles of OOD but it makes // the point about the syntax. KeepForever.keepMe[index] = newByte; }
, , , GC'd. , , .
. https://highlyscalable.wordpress.com/2012/02/02/direct-memory-access-in-java/. JVM, , , .
Source: https://habr.com/ru/post/1712360/More articles:How to keep div focus when mouse enters node child - javascriptTokenizing Strings - vba"Sliding window" - is it possible to add reliability to the protocol and avoid flow control? - cDownloading your own DLL as a debugging module in C # managed code for Windows CE - c ++Unable to set breakpoints in C DLLs used by C ++ / CLI called from C # - debuggingUsing C # to print large images across multiple pages - c #Symbol CATransform3DMakeRotation Not Found - iphoneCan you know how big a factorial is before calculating it? - language-agnosticРазработка С++ для Linux в Windows - c++https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1712365/why-doesnt-moz-border-radius-topright-work-in-google-chrome&usg=ALkJrhjzXfD2glTush52v6d-099Y7pEa1AAll Articles