I've got a question about the garbage collector on iOS.
I've got 2 Objective-C libraries where one asks for a NSData object and the other one can be used to query for a NSData object. My Kotlin code does some bridging between them but does nothing with the NSData object besides return it through several layers of function calls.
These NSData objects hold about 1 MB of data each. We had a bug with the query library where it was asking for the same 9 data every 15 ms, when it gets the object it replaces the old one in a std::map. What I found was that the memory of the app would quickly cycle from 200MB to 1GB and then drop back to 200MB and repeat. In another app, it just crashed with an out of memory error.
I assume the dropping back down happens due to the Kotlin garbage collector releasing its retain on the object and allowing it to be garbage collected. What I wonder is whether there is any way to tell Kotlin that I don't care about the object anymore once I hand it off so that it can be deallocated once the Objective-C code is done? I tried wrapping the load call in an `autoreleasePool`but that didn't help. I assume because we retain the object after the pool so that it can be returned to the first library.