Hi,
First of all, thanks Tom for all your help previously regarding Xalan, and for this great project.
Everything seemed to be working swimmingly but coming up to release, I caught a memory leak while profiling memory use of our app. Using Instruments, I traced the leak to a couple of different complex retain cycles that appears to be occurring inside of the Apache Harmony XML code. Instruments shows 11 simple cycles (4 unique kinds) making up this first of the three kinds of complex cycles.
The first simple cycle is:
OrgApacheHarmonyXmlDomElementImpl --- id <JavaUtilList> children_ --->
JavaUtilArrayList ---- IOSObjectArray* array_ ----->
IOSObjectArray ---- id buffer [0] ---->
OrgApacheHarmonyXmlDomTextImpl --- OrgApacheHarmonyXmlDomInnerNodeImpl* parent_ ---> BACK TO TOP (retain cycle)
Before I go into details on all the rest, I want to ask what the best approach to this would be. I read up on the memory management annotations that j2objc features, and the use of cycle finder. I tried running cycle finder between ElementImpl.java and TextImpl.java:
cycle_finder -classpath j2objc/dist/lib j2objc/jre_emul/android/libcore/luni/src/main/java/org/apache/harmony/xml//dom/ElementImpl.java j2objc/jre_emul/android/libcore/luni/src/main/java/org/apache/harmony/xml//dom/TextImpl.java
However, I got hundreds of errors. I don't even know where to begin with that.
I reviewed the "Memory Management" section of J2ObjC's online documentation, and reviewed the J2ObjC annotations related to memory management. So I added @Weak in the Apache Harmony java sourcecode front of the properties that Instruments reveals as being the offending references that are causing the retain cycles.
This seemed to fix the problem.
I also found some similar leaks due to retain cycles inside of Xalan, and added @Weak to some properties in there as well. But there, I ran into the problem that import com.google.j2objc.annotations.Weak; fails inside of Xalan because Xalan cannot see that, since you put Xalan outside the main source code.
How do I set things up where I can use @Weak inside of the Xalan source? I'm at a loss.
Thanks
Jon Gilbert