I would like to optimize the reading of an InputStream, then I thought it would be nice to have a byte buffer [] with a RAM page size.
Is there a way (possibly static) to know its size?
EDIT:
Finally, I managed to use NDK and JNI, I wrote the following code in C:
#include <jni.h> #include <unistd.h> jlong Java_it_masmil_tests_TestsActivity_pageSize(JNIEnv* env, jobject javaThis) { return sysconf(_SC_PAGE_SIZE); }
Where:
- it.masmil.tests is the name of the package
- TestsActivity is the name of the class.
- pageSize is the name of the method
- env and javaThis are two required parameters (useful in some cases)
I compiled this file with the NDK and then wrote the following code in Java:
static { System.loadLibrary("clibrary"); } private native long pageSize(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); long page = pageSize(); }
Where:
- clibrary is the name of the library I created using the NDK
- pageSize is the name of the method declared in the C file
source share