Can you pack and reuse pointers? Trying to make LibRealsense garbage free #532
Replies: 2 comments 12 replies
-
If you're talking about deterministic deallocation, we can do that with Pointer.close(), but PointerScope is more convenient: |
Beta Was this translation helpful? Give feedback.
-
I may not be describing it well so code might just be easier? I just don't want to call new. It looks like polling allows us to pack rs2_frame without allocating. rs2_get_frame_data requires a new BytePointer though. I just want to reuse it every tick. I was looking at manually calling deallocate, null, then init on the packablePointer, but I haven't tried it yet.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Saudet!
I am trying to get depth data from a few real sense cameras into a real time java thread and I would like to avoid calling the GC if possible. I was able to profile and it looks like most of the allocations on the Java side are related to new pointer allocations (Pointer, rs2_frame, and rs2_stream_profile). Do you know if it's possible to reuse pointers instead of creating new ones each javacpp call? I think we can manually call the deallocation of native memory within the realtime thread once we are done with the byte buffers. I don't fully understand how the pointers get allocated and managed under the hood, so I am not really sure where to go from here.
Javacpp is very helpful, Thank you!
Beta Was this translation helpful? Give feedback.
All reactions