Hello there,
Is it possible that the camera functions or somewhere else are having a memory leak? This is a very critical bug, on an app that takes many pictures from the camera daily.
The app is already developed for a good time, and seems like it didn’t happen before. But after doing some heavy use of the camera, the memory usage reported by android goes way high (maxs on around 200Mb, when the app gets killed later), while the in code memory (from lua garbage collector) displays 1 or 2Mbs of RAM and around 10-15Mbytes of video memory.
The story does not end here. On android 4.1.2 (tested on samsung S3), the app just dies after reaching some high memory, however, on a nexus 4 (android 4.4.2) not only the app crashes, but the operative system is unable to recover the leaked memory. From a 2GB device, it ends up with around 180MB free RAM after taking pictures for 5 minutes. The app dies and the device needs to be restarted.
Pictures are saved to disk (storage) with the media.capturePhoto function. And then used and deleted later. I doubt that this helps, but “using” the image includes opening it, loading it into memory, convert it to base64, send it to a server though an HTTP POST request, closing the file, and deleting the file.
However, this only happens if the user has internet access, otherwise, picture files are saved and not touched by anything, yet the problem still happens this way.