Hi,
I ran instruments on our j2objc based app to check for memory leaks. We are using protocol buffers for multiple purposes in our app - for communication, state persistence or so. What I realised was that every protobuf message was flagged as memory leak in Instruments.
I just made simple .proto and simple Java class to be sure that this is protocol buffers problem and not something else in our app. The simple .proto file:
syntax = "proto3";
package comm;
option java_package = "pb";
option java_outer_classname = "PbComm";
message TestMessage {
string text = 1;
int32 number = 2;
}
and very simple class, that just creates message 10 times in a second:
import com.google.j2objc.annotations.AutoreleasePool;
import pb.PbComm;
import java.util.Timer;
import java.util.TimerTask;
public class ProtoBuffTest {
Timer timer;
public void startTest() {
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
periodicTestTask();
}
}, 0, 100);
}
@AutoreleasePool private void periodicTestTask() {
PbComm.TestMessage testMessage = PbComm.TestMessage.newBuilder()
.setNumber(1)
.build();
System.out.println("Message size: " + testMessage.getSerializedSize());
}
}
We are using arc in java translated files and we are using "--swift-friendly -use-arc --nullability -g --no-package-directories --static-accessor-methods -Xforce-incomplete-java8 -source 8" j2objc params.
Any idea, what may be the reason for those memory leaks? I even tried to use j2objc ver. 2.8 (normally we are using newer j2objc from git), but the problem is still there.
Thanks,
Jindrich