0

My use-case for NDK primarily is not speed but to avoid memory limitation. To be exact I need to capture full resolution images at 60 fps for few seconds until it occupies all my free RAM (which will be 3 GB out of total 4 GB in my hardware).

Since the capture speed is very fast, I can't process the images in parallel. So I want to put them in RAM on Camera2 API onImageAvailable listener callback and later retrieve them from RAM to process slowly one by one.

1) Is it even feasible to occupy all available memory or 75% of total device memory?

2) And how I can just pass objects in NDK to store in memory and later get them all in Java again.

Umair
  • 1,206
  • 1
  • 13
  • 28
  • System kills your app much earlier than you occupy mentioned amount of memory. And actual moment of killing is unpredictable since it depends on actual system-wide resource usage level. Just play with `malloc()` enclosed into loop and you'll see it. So it is very risky to allocate such amounts of memory. – Sergio Dec 17 '16 at 15:49
  • "Is it even feasible to occupy all available memory" -- Android will terminate your process before then. "And how I can just pass objects in NDK to store in memory" -- you don't have objects. Images from the camera are `byte[]`. I think that turns into [`jbytearray`](http://stackoverflow.com/a/4083678/115145). You would copy from there to some memory buffer that you `malloc()`. Have some separate JNI function to [return the data](http://stackoverflow.com/questions/10383458/returning-jbytearray-from-native-c-in-android). – CommonsWare Dec 24 '16 at 16:11

0 Answers0