I have inherited a rather large code base that includes a number of external libraries, and am completely new to java/android/app development; sorry if some of my terminology is off or I am missing necessary information.
I have an application that has a display thread that uses unity (com.unity3d.player). Additionally, in what I believe to be a background thread, the application subscribes to ROS messages (using the external ROSjava/rosandroid libraries, although pulled in locally with some small modification). This causes a large amount of object creation, I think all coming from reading the ROS messages (and deserializing, putting the data in hashmaps, and later getting it) which leads to a lot of garbage collection, which freezes the app. I eventually get a "suspending all threads" message.
I note that the application is not maxing out at a lot of memory, so I was wondering if there was a way to force it to allocate more memory rapidly instead of garbage collecting and freezing. In searching I have also come across object pooling as a solution to this problem, but have also found people saying this just interferes with GC unnecessarily; could adding object pooling in the message reading portion help my situation? I know I would need to implement this in such a way that the data was still buffering correctly so it wouldn't be lost, somehow.
Thanks for any advice you can provide. Here are some screenshots showing the memory allocation problem threads.