jni, native methods and access to shared memory
i have a c library that manages shared memory and other stuff... i can't modify it but i want to use it from java (i want to create a thing similar to a wrapper). i'm using jni, and i have a class buffer with an attribute byte that should always be a "copy" of the content of the buffer. my opinion is that is unsafe to have an object copy of the buffer because the buffer can be modified (accidentally) by other processes and so the buffer wouldn't be exactly like the java object. Moreover it implies that when i recognize that the buffer changed, i have to update the java object (it can be hard). finally copying the buffer into an object means double the memory usage.
my idea was to store in the java object only an id of the buffer, and then get info through get methods that call c native methods each time (i know it's expensive, but i prefer slow things that work)
do you think i must have a java object storing all the content of the buffer or it's better to have a java object that stores only an id of the buffer?
|All times are GMT. The time now is 06:52 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.